2
我正在使用Django 1.3,並且想修改會話中間件以添加一些方法來幫助我。擴展會話中間件
在./settings.py
SESSION_ENGINE='tcore.my_sessions.MySessionStore'
在./tcore/my_sessions.py:
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.middleware import SessionMiddleware
from django.conf import settings
class MySessionStore(SessionStore):
....
def my custom methods here
不過,我不斷收到一些奇怪的例外當我這樣做。制定自定義會話引擎的正確方法是什麼?
AttributeError at /create/
type object 'MySessionStore' has no attribute 'SessionStore'
Request Method: GET
Request URL: http://localhost:8000/create/
Django Version: 1.3.1
Exception Type: AttributeError
Exception Value:
type object 'MySessionStore' has no attribute 'SessionStore'
Python Version: 2.6.1
感謝JPIC。我會試一試,讓你知道它是如何運作的。感謝您的幫助。 – 2012-03-07 18:09:26
爲了進一步評論,當我需要提供包含該類的模塊的路徑時,似乎我正在提供實際SessionStore類的路徑。謝謝你澄清這一點。 – 2012-03-07 18:12:02