diff options
author | root <root@u15356270.onlinehome-server.com> | 2009-11-13 20:18:31 -0500 |
---|---|---|
committer | root <root@u15356270.onlinehome-server.com> | 2009-11-13 20:31:16 -0500 |
commit | 40b5c06085fe3d079094e8ef779a7b119586f9e8 (patch) | |
tree | 5a3edfb81cc137dbc877f75f9bde80e9720b3ba0 /session_messages | |
parent | 2022b772a01f36fa74de002b5370dd70b6c051ba (diff) | |
download | askbot-40b5c06085fe3d079094e8ef779a7b119586f9e8.tar.gz askbot-40b5c06085fe3d079094e8ef779a7b119586f9e8.tar.bz2 askbot-40b5c06085fe3d079094e8ef779a7b119586f9e8.zip |
better comments, email subscriptions, corrected view counter, some ie7 issues, wiki optional with settings.WIKI_ON, site can be mounted on arbitrary url prefix, english language improvements, added feedback form, versioned css and js files to force browser cache reload when settings.RESOURCE_REVISION is incremented , other fixes
Diffstat (limited to 'session_messages')
-rw-r--r-- | session_messages/.svn/all-wcprops | 23 | ||||
-rw-r--r-- | session_messages/.svn/dir-prop-base | 6 | ||||
-rw-r--r-- | session_messages/.svn/entries | 64 | ||||
-rw-r--r-- | session_messages/.svn/format | 1 | ||||
-rw-r--r-- | session_messages/.svn/text-base/__init__.py.svn-base | 36 | ||||
-rw-r--r-- | session_messages/.svn/text-base/context_processors.py.svn-base | 48 | ||||
-rw-r--r-- | session_messages/.svn/text-base/models.py.svn-base | 3 | ||||
-rw-r--r-- | session_messages/__init__.py | 37 | ||||
-rw-r--r-- | session_messages/context_processors.py | 48 | ||||
-rw-r--r-- | session_messages/models.py | 3 |
10 files changed, 269 insertions, 0 deletions
diff --git a/session_messages/.svn/all-wcprops b/session_messages/.svn/all-wcprops new file mode 100644 index 00000000..2a15b353 --- /dev/null +++ b/session_messages/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 38 +/svn/!svn/ver/5/trunk/session_messages +END +__init__.py +K 25 +svn:wc:ra_dav:version-url +V 50 +/svn/!svn/ver/5/trunk/session_messages/__init__.py +END +models.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/2/trunk/session_messages/models.py +END +context_processors.py +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/!svn/ver/2/trunk/session_messages/context_processors.py +END diff --git a/session_messages/.svn/dir-prop-base b/session_messages/.svn/dir-prop-base new file mode 100644 index 00000000..4cc643b7 --- /dev/null +++ b/session_messages/.svn/dir-prop-base @@ -0,0 +1,6 @@ +K 10 +svn:ignore +V 6 +*.pyc + +END diff --git a/session_messages/.svn/entries b/session_messages/.svn/entries new file mode 100644 index 00000000..67c0db8a --- /dev/null +++ b/session_messages/.svn/entries @@ -0,0 +1,64 @@ +8 + +dir +5 +http://django-session-messages.googlecode.com/svn/trunk/session_messages +http://django-session-messages.googlecode.com/svn + + + +2009-03-10T23:30:03.043791Z +5 +carl.j.meyer +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +b8288d2d-7354-0410-af5b-714f73743f4b + +__init__.py +file + + + + +2009-10-25T23:36:02.000000Z +89aa0f71c9973e4889e5fad0b4771a34 +2009-03-10T23:30:03.043791Z +5 +carl.j.meyer + +models.py +file + + + + +2009-10-25T23:36:02.000000Z +c5b4f274dbb06bc66a14f0c18c9115cd +2008-08-14T23:13:23.180432Z +2 +carl.j.meyer + +context_processors.py +file + + + + +2009-10-25T23:36:02.000000Z +24779c7e504d3f7f1918fdf3fe8096bc +2008-08-14T23:13:23.180432Z +2 +carl.j.meyer + diff --git a/session_messages/.svn/format b/session_messages/.svn/format new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/session_messages/.svn/format @@ -0,0 +1 @@ +8 diff --git a/session_messages/.svn/text-base/__init__.py.svn-base b/session_messages/.svn/text-base/__init__.py.svn-base new file mode 100644 index 00000000..0136c888 --- /dev/null +++ b/session_messages/.svn/text-base/__init__.py.svn-base @@ -0,0 +1,36 @@ +""" +Lightweight session-based messaging system. + +Time-stamp: <2009-03-10 19:22:29 carljm __init__.py> + +""" +VERSION = (0, 1, 'pre') + +def create_message (request, message): + """ + Create a message in the current session. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + try: + request.session['messages'].append(message) + except KeyError: + request.session['messages'] = [message] + +def get_and_delete_messages (request, include_auth=False): + """ + Get and delete all messages for current session. + + Optionally also fetches user messages from django.contrib.auth. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + messages = request.session.pop('messages', []) + + if include_auth and request.user.is_authenticated(): + messages.extend(request.user.get_and_delete_messages()) + + return messages + diff --git a/session_messages/.svn/text-base/context_processors.py.svn-base b/session_messages/.svn/text-base/context_processors.py.svn-base new file mode 100644 index 00000000..df9840fd --- /dev/null +++ b/session_messages/.svn/text-base/context_processors.py.svn-base @@ -0,0 +1,48 @@ +""" +Context processor for lightweight session messages. + +Time-stamp: <2008-07-19 23:16:19 carljm context_processors.py> + +""" +from django.utils.encoding import StrAndUnicode + +from session_messages import get_and_delete_messages + +def session_messages (request): + """ + Returns session messages for the current session. + + """ + return { 'session_messages': LazyMessages(request) } + +class LazyMessages (StrAndUnicode): + """ + Lazy message container, so messages aren't actually retrieved from + session and deleted until the template asks for them. + + """ + def __init__(self, request): + self.request = request + + def __iter__(self): + return iter(self.messages) + + def __len__(self): + return len(self.messages) + + def __nonzero__(self): + return bool(self.messages) + + def __unicode__(self): + return unicode(self.messages) + + def __getitem__(self, *args, **kwargs): + return self.messages.__getitem__(*args, **kwargs) + + def _get_messages(self): + if hasattr(self, '_messages'): + return self._messages + self._messages = get_and_delete_messages(self.request) + return self._messages + messages = property(_get_messages) + diff --git a/session_messages/.svn/text-base/models.py.svn-base b/session_messages/.svn/text-base/models.py.svn-base new file mode 100644 index 00000000..b67ead6d --- /dev/null +++ b/session_messages/.svn/text-base/models.py.svn-base @@ -0,0 +1,3 @@ +""" +blank models.py +""" diff --git a/session_messages/__init__.py b/session_messages/__init__.py new file mode 100644 index 00000000..4dd10a6b --- /dev/null +++ b/session_messages/__init__.py @@ -0,0 +1,37 @@ +""" +Lightweight session-based messaging system. + +Time-stamp: <2009-03-10 19:22:29 carljm __init__.py> + +""" +VERSION = (0, 1, 'pre') + +def create_message (request, message): + """ + Create a message in the current session. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + try: + request.session['messages'].append(message) + except KeyError: + request.session['messages'] = [message] + +def get_and_delete_messages (request, include_auth=False): + """ + Get and delete all messages for current session. + + Optionally also fetches user messages from django.contrib.auth. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + messages = request.session.pop('messages', []) + import logging + + if include_auth and request.user.is_authenticated(): + messages.extend(request.user.get_and_delete_messages()) + + return messages + diff --git a/session_messages/context_processors.py b/session_messages/context_processors.py new file mode 100644 index 00000000..df9840fd --- /dev/null +++ b/session_messages/context_processors.py @@ -0,0 +1,48 @@ +""" +Context processor for lightweight session messages. + +Time-stamp: <2008-07-19 23:16:19 carljm context_processors.py> + +""" +from django.utils.encoding import StrAndUnicode + +from session_messages import get_and_delete_messages + +def session_messages (request): + """ + Returns session messages for the current session. + + """ + return { 'session_messages': LazyMessages(request) } + +class LazyMessages (StrAndUnicode): + """ + Lazy message container, so messages aren't actually retrieved from + session and deleted until the template asks for them. + + """ + def __init__(self, request): + self.request = request + + def __iter__(self): + return iter(self.messages) + + def __len__(self): + return len(self.messages) + + def __nonzero__(self): + return bool(self.messages) + + def __unicode__(self): + return unicode(self.messages) + + def __getitem__(self, *args, **kwargs): + return self.messages.__getitem__(*args, **kwargs) + + def _get_messages(self): + if hasattr(self, '_messages'): + return self._messages + self._messages = get_and_delete_messages(self.request) + return self._messages + messages = property(_get_messages) + diff --git a/session_messages/models.py b/session_messages/models.py new file mode 100644 index 00000000..b67ead6d --- /dev/null +++ b/session_messages/models.py @@ -0,0 +1,3 @@ +""" +blank models.py +""" |