Changeset 6371
- Timestamp:
- 09/17/07 10:49:03 (10 months ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/AUTHORS (modified) (4 diffs)
- django/branches/newforms-admin/django/bin/compile-messages.py (modified) (2 diffs)
- django/branches/newforms-admin/django/conf/global_settings.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/admin/views/main.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/sessions/backends (copied) (copied from django/trunk/django/contrib/sessions/backends)
- django/branches/newforms-admin/django/contrib/sessions/backends/base.py (copied) (copied from django/trunk/django/contrib/sessions/backends/base.py)
- django/branches/newforms-admin/django/contrib/sessions/backends/cache.py (copied) (copied from django/trunk/django/contrib/sessions/backends/cache.py)
- django/branches/newforms-admin/django/contrib/sessions/backends/db.py (copied) (copied from django/trunk/django/contrib/sessions/backends/db.py)
- django/branches/newforms-admin/django/contrib/sessions/backends/file.py (copied) (copied from django/trunk/django/contrib/sessions/backends/file.py)
- django/branches/newforms-admin/django/contrib/sessions/backends/__init__.py (copied) (copied from django/trunk/django/contrib/sessions/backends/__init__.py)
- django/branches/newforms-admin/django/contrib/sessions/middleware.py (modified) (4 diffs)
- django/branches/newforms-admin/django/contrib/sessions/models.py (modified) (2 diffs)
- django/branches/newforms-admin/django/contrib/sessions/tests.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/context_processors.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/handlers/modpython.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/models/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/newforms-admin/django/middleware/http.py (modified) (1 diff)
- django/branches/newforms-admin/django/newforms/fields.py (modified) (2 diffs)
- django/branches/newforms-admin/django/newforms/forms.py (modified) (3 diffs)
- django/branches/newforms-admin/django/test/client.py (modified) (5 diffs)
- django/branches/newforms-admin/django/utils/datastructures.py (modified) (2 diffs)
- django/branches/newforms-admin/django/utils/dateformat.py (modified) (1 diff)
- django/branches/newforms-admin/django/utils/timesince.py (modified) (3 diffs)
- django/branches/newforms-admin/docs/apache_auth.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/django-admin.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/email.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/i18n.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/install.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/model-api.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/newforms.txt (modified) (3 diffs)
- django/branches/newforms-admin/docs/sessions.txt (modified) (5 diffs)
- django/branches/newforms-admin/docs/settings.txt (modified) (3 diffs)
- django/branches/newforms-admin/docs/templates.txt (modified) (2 diffs)
- django/branches/newforms-admin/tests/modeltests/basic/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/custom_pk/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/fixtures/models.py (modified) (3 diffs)
- django/branches/newforms-admin/tests/regressiontests/backends/models.py (modified) (3 diffs)
- django/branches/newforms-admin/tests/regressiontests/forms/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/templates/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/utils/tests.py (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/utils/timesince.py (copied) (copied from django/trunk/tests/regressiontests/utils/timesince.py)
- django/branches/newforms-admin/tests/regressiontests/views (copied) (copied from django/trunk/tests/regressiontests/views)
- django/branches/newforms-admin/tests/regressiontests/views/fixtures (copied) (copied from django/trunk/tests/regressiontests/views/fixtures)
- django/branches/newforms-admin/tests/regressiontests/views/fixtures/testdata.json (copied) (copied from django/trunk/tests/regressiontests/views/fixtures/testdata.json)
- django/branches/newforms-admin/tests/regressiontests/views/__init__.py (copied) (copied from django/trunk/tests/regressiontests/views/__init__.py)
- django/branches/newforms-admin/tests/regressiontests/views/locale (copied) (copied from django/trunk/tests/regressiontests/views/locale)
- django/branches/newforms-admin/tests/regressiontests/views/locale/en (copied) (copied from django/trunk/tests/regressiontests/views/locale/en)
- django/branches/newforms-admin/tests/regressiontests/views/locale/en/LC_MESSAGES (copied) (copied from django/trunk/tests/regressiontests/views/locale/en/LC_MESSAGES)
- django/branches/newforms-admin/tests/regressiontests/views/locale/en/LC_MESSAGES/djangojs.mo (copied) (copied from django/trunk/tests/regressiontests/views/locale/en/LC_MESSAGES/djangojs.mo)
- django/branches/newforms-admin/tests/regressiontests/views/locale/en/LC_MESSAGES/djangojs.po (copied) (copied from django/trunk/tests/regressiontests/views/locale/en/LC_MESSAGES/djangojs.po)
- django/branches/newforms-admin/tests/regressiontests/views/locale/es (copied) (copied from django/trunk/tests/regressiontests/views/locale/es)
- django/branches/newforms-admin/tests/regressiontests/views/locale/es/LC_MESSAGES (copied) (copied from django/trunk/tests/regressiontests/views/locale/es/LC_MESSAGES)
- django/branches/newforms-admin/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo (copied) (copied from django/trunk/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo)
- django/branches/newforms-admin/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po (copied) (copied from django/trunk/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po)
- django/branches/newforms-admin/tests/regressiontests/views/locale/fr (copied) (copied from django/trunk/tests/regressiontests/views/locale/fr)
- django/branches/newforms-admin/tests/regressiontests/views/locale/fr/LC_MESSAGES (copied) (copied from django/trunk/tests/regressiontests/views/locale/fr/LC_MESSAGES)
- django/branches/newforms-admin/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo (copied) (copied from django/trunk/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo)
- django/branches/newforms-admin/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po (copied) (copied from django/trunk/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po)
- django/branches/newforms-admin/tests/regressiontests/views/media (copied) (copied from django/trunk/tests/regressiontests/views/media)
- django/branches/newforms-admin/tests/regressiontests/views/media/file.txt (copied) (copied from django/trunk/tests/regressiontests/views/media/file.txt)
- django/branches/newforms-admin/tests/regressiontests/views/models.py (copied) (copied from django/trunk/tests/regressiontests/views/models.py)
- django/branches/newforms-admin/tests/regressiontests/views/tests (copied) (copied from django/trunk/tests/regressiontests/views/tests)
- django/branches/newforms-admin/tests/regressiontests/views/tests/defaults.py (copied) (copied from django/trunk/tests/regressiontests/views/tests/defaults.py)
- django/branches/newforms-admin/tests/regressiontests/views/tests/i18n.py (copied) (copied from django/trunk/tests/regressiontests/views/tests/i18n.py)
- django/branches/newforms-admin/tests/regressiontests/views/tests/__init__.py (copied) (copied from django/trunk/tests/regressiontests/views/tests/__init__.py)
- django/branches/newforms-admin/tests/regressiontests/views/tests/static.py (copied) (copied from django/trunk/tests/regressiontests/views/tests/static.py)
- django/branches/newforms-admin/tests/regressiontests/views/urls.py (copied) (copied from django/trunk/tests/regressiontests/views/urls.py)
- django/branches/newforms-admin/tests/regressiontests/views/views.py (copied) (copied from django/trunk/tests/regressiontests/views/views.py)
- django/branches/newforms-admin/tests/urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6332 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6370
django/branches/newforms-admin/AUTHORS
r6342 r6371 85 85 colin@owlfish.com 86 86 crankycoder@gmail.com 87 Paul Collier <paul@paul-collier.com> 87 88 Pete Crosier <pete.crosier@gmail.com> 88 89 Matt Croydon <http://www.postneo.com/> 89 90 flavio.curella@gmail.com 90 91 Jure Cuhalev <gandalf@owca.info> 92 John D'Agostino <john.dagostino@gmail.com> 91 93 dackze+django@gmail.com 92 94 David Danier <goliath.mailinglist@gmx.de> … … 122 124 Matthew Flanagan <http://wadofstuff.blogspot.com> 123 125 Eric Floehr <eric@intellovations.com> 126 Vincent Foley <vfoleybourgon@yahoo.ca> 124 127 Jorge Gajon <gajon@gajon.org> 125 128 gandalf@owca.info … … 196 199 limodou 197 200 Philip Lindborg <philip.lindborg@gmail.com> 201 <<<<<<< .working 198 202 Simon Litchfield <simon@quo.com.au> 203 ======= 204 msaelices <msaelices@gmail.com> 205 >>>>>>> .merge-right.r6370 199 206 Matt McClanahan <http://mmcc.cx/> 200 207 Martin Maney <http://www.chipy.org/Martin_Maney> … … 263 270 Oliver Rutherfurd <http://rutherfurd.net/> 264 271 ryankanno 272 Manuel Saelices <msaelices@yaco.es> 265 273 Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/> 266 274 Vinay Sajip <vinay_sajip@yahoo.co.uk> django/branches/newforms-admin/django/bin/compile-messages.py
r4940 r6371 5 5 import sys 6 6 7 try: 8 set 9 except NameError: 10 from sets import Set as set # For Python 2.3 11 12 7 13 def compile_messages(locale=None): 8 basedir = None 14 basedirs = [os.path.join('conf', 'locale'), 'locale'] 15 if os.environ.get('DJANGO_SETTINGS_MODULE'): 16 from django.conf import settings 17 basedirs += settings.LOCALE_PATHS 9 18 10 if os.path.isdir(os.path.join('conf', 'locale')): 11 basedir = os.path.abspath(os.path.join('conf', 'locale')) 12 elif os.path.isdir('locale'): 13 basedir = os.path.abspath('locale') 14 else: 15 print "This script should be run from the Django SVN tree or your project or app tree." 19 # Gather existing directories. 20 basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs))) 21 22 if not basedirs: 23 print "This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified." 16 24 sys.exit(1) 17 25 18 if locale is not None: 19 basedir = os.path.join(basedir, locale, 'LC_MESSAGES') 26 for basedir in basedirs: 27 if locale: 28 basedir = os.path.join(basedir, locale, 'LC_MESSAGES') 29 compile_messages_in_dir(basedir) 20 30 31 def compile_messages_in_dir(basedir): 21 32 for dirpath, dirnames, filenames in os.walk(basedir): 22 33 for f in filenames: … … 41 52 parser.add_option('-l', '--locale', dest='locale', 42 53 help="The locale to process. Default is to process all.") 54 parser.add_option('--settings', 55 help='Python path to settings module, e.g. "myproject.settings". If provided, all LOCALE_PATHS will be processed. If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be checked as well.') 43 56 options, args = parser.parse_args() 44 57 if len(args): 45 58 parser.error("This program takes no arguments") 59 if options.settings: 60 os.environ['DJANGO_SETTINGS_MODULE'] = options.settings 46 61 compile_messages(options.locale) 47 62 django/branches/newforms-admin/django/conf/global_settings.py
r6342 r6371 272 272 ############ 273 273 274 SESSION_COOKIE_NAME = 'sessionid' # Cookie name. This can be whatever you want. 275 SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2 # Age of cookie, in seconds (default: 2 weeks). 276 SESSION_COOKIE_DOMAIN = None # A string like ".lawrence.com", or None for standard domain cookie. 277 SESSION_COOKIE_SECURE = False # Whether the session cookie should be secure (https:// only). 278 SESSION_SAVE_EVERY_REQUEST = False # Whether to save the session data on every request. 279 SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Whether sessions expire when a user closes his browser. 274 SESSION_COOKIE_NAME = 'sessionid' # Cookie name. This can be whatever you want. 275 SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2 # Age of cookie, in seconds (default: 2 weeks). 276 SESSION_COOKIE_DOMAIN = None # A string like ".lawrence.com", or None for standard domain cookie. 277 SESSION_COOKIE_SECURE = False # Whether the session cookie should be secure (https:// only). 278 SESSION_SAVE_EVERY_REQUEST = False # Whether to save the session data on every request. 279 SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Whether sessions expire when a user closes his browser. 280 SESSION_ENGINE = 'django.contrib.sessions.backends.db' # The module to store session data 281 SESSION_FILE_PATH = '/tmp/' # Directory to store session files if using the file session module 280 282 281 283 ######### django/branches/newforms-admin/django/contrib/admin/views/main.py
r6216 r6371 86 86 def original_value(self): 87 87 if self.original: 88 return self.original.__dict__[self.field. column]88 return self.original.__dict__[self.field.attname] 89 89 90 90 def existing_display(self): django/branches/newforms-admin/django/contrib/sessions/middleware.py
r5828 r6371 1 1 from django.conf import settings 2 from django.contrib.sessions.models import Session3 from django.core.exceptions import SuspiciousOperation4 2 from django.utils.cache import patch_vary_headers 5 3 from email.Utils import formatdate … … 10 8 TEST_COOKIE_VALUE = 'worked' 11 9 12 class SessionWrapper(object): 13 def __init__(self, session_key): 14 self.session_key = session_key 15 self.accessed = False 16 self.modified = False 10 class SessionMiddleware(object): 17 11 18 def __contains__(self, key):19 return key in self._session20 21 def __getitem__(self, key):22 return self._session[key]23 24 def __setitem__(self, key, value):25 self._session[key] = value26 self.modified = True27 28 def __delitem__(self, key):29 del self._session[key]30 self.modified = True31 32 def keys(self):33 return self._session.keys()34 35 def items(self):36 return self._session.items()37 38 def get(self, key, default=None):39 return self._session.get(key, default)40 41 def pop(self, key, *args):42 self.modified = self.modified or key in self._session43 return self._session.pop(key, *args)44 45 def set_test_cookie(self):46 self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE47 48 def test_cookie_worked(self):49 return self.get(TEST_COOKIE_NAME) == TEST_COOKIE_VALUE50 51 def delete_test_cookie(self):52 del self[TEST_COOKIE_NAME]53 54 def _get_session(self):55 # Lazily loads session from storage.56 self.accessed = True57 try:58 return self._session_cache59 except AttributeError:60 if self.session_key is None:61 self._session_cache = {}62 else:63 try:64 s = Session.objects.get(session_key=self.session_key,65 expire_date__gt=datetime.datetime.now())66 self._session_cache = s.get_decoded()67 except (Session.DoesNotExist, SuspiciousOperation):68 self._session_cache = {}69 # Set the session_key to None to force creation of a new70 # key, for extra security.71 self.session_key = None72 return self._session_cache73 74 _session = property(_get_session)75 76 class SessionMiddleware(object):77 12 def process_request(self, request): 78 request.session = SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) 13 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 14 request.session = engine.SessionStore(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) 79 15 80 16 def process_response(self, request, response): … … 90 26 patch_vary_headers(response, ('Cookie',)) 91 27 if modified or settings.SESSION_SAVE_EVERY_REQUEST: 92 if request.session.session_key:93 session_key = request.session.session_key94 else:95 obj = Session.objects.get_new_session_object()96 session_key = obj.session_key97 98 28 if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE: 99 29 max_age = None … … 102 32 max_age = settings.SESSION_COOKIE_AGE 103 33 rfcdate = formatdate(time.time() + settings.SESSION_COOKIE_AGE) 34 104 35 # Fixed length date must have '-' separation in the format 105 36 # DD-MMM-YYYY for compliance with Netscape cookie standard 106 expires = (rfcdate[:7] + "-" + rfcdate[8:11] 107 + "-" + rfcdate[12:26] + "GMT") 108 new_session = Session.objects.save(session_key, request.session._session, 109 datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)) 110 response.set_cookie(settings.SESSION_COOKIE_NAME, session_key, 37 expires = datetime.datetime.strftime(datetime.datetime.utcnow() + \ 38 datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT") 39 40 # Save the seesion data and refresh the client cookie. 41 request.session.save() 42 response.set_cookie(settings.SESSION_COOKIE_NAME, request.session.session_key, 111 43 max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN, 112 44 secure=settings.SESSION_COOKIE_SECURE or None) 45 113 46 return response django/branches/newforms-admin/django/contrib/sessions/models.py
r6342 r6371 1 import base64, md5, random, sys, datetime , os, time1 import base64, md5, random, sys, datetime 2 2 import cPickle as pickle 3 3 from django.db import models … … 75 75 expire_date = models.DateTimeField(_('expire date')) 76 76 objects = SessionManager() 77 77 78 class Meta: 78 79 db_table = 'django_session' django/branches/newforms-admin/django/contrib/sessions/tests.py
r5918 r6371 1 1 r""" 2 >>> s = SessionWrapper(None)3 2 4 Inject data into the session cache. 5 >>> s._session_cache = {}6 >>> s._session_cache['some key'] = 'exists'3 >>> from django.contrib.sessions.backends.db import SessionStore as DatabaseSession 4 >>> from django.contrib.sessions.backends.cache import SessionStore as CacheSession 5 >>> from django.contrib.sessions.backends.file import SessionStore as FileSession 7 6 8 >>> s.accessed 7 >>> db_session = DatabaseSession() 8 >>> db_session.modified 9 9 False 10 >>> s.modified 10 >>> db_session['cat'] = "dog" 11 >>> db_session.modified 12 True 13 >>> db_session.pop('cat') 14 'dog' 15 >>> db_session.pop('some key', 'does not exist') 16 'does not exist' 17 >>> db_session.save() 18 >>> db_session.exists(db_session.session_key) 19 True 20 >>> db_session.delete(db_session.session_key) 21 >>> db_session.exists(db_session.session_key) 11 22 False 12 23 13 >>> s.pop('non existant key', 'does not exist') 24 >>> file_session = FileSession() 25 >>> file_session.modified 26 False 27 >>> file_session['cat'] = "dog" 28 >>> file_session.modified 29 True 30 >>> file_session.pop('cat') 31 'dog' 32 >>> file_session.pop('some key', 'does not exist') 14 33 'does not exist' 15 >>> s.accessed 34 >>> file_session.save() 35 >>> file_session.exists(file_session.session_key) 16 36 True 17 >>> s.modified 37 >>> file_session.delete(file_session.session_key) 38 >>> file_session.exists(file_session.session_key) 18 39 False 19 40 20 >>> s.pop('some key') 21 'exists' 22 >>> s.accessed 41 >>> cache_session = CacheSession() 42 >>> cache_session.modified 43 False 44 >>> cache_session['cat'] = "dog" 45 >>> cache_session.modified 23 46 True 24 >>> s.modified 25 True 26 27 >>> s.pop('some key', 'does not exist') 47 >>> cache_session.pop('cat') 48 'dog' 49 >>> cache_session.pop('some key', 'does not exist') 28 50 'does not exist' 51 >>> cache_session.save() 52 >>> cache_session.delete(cache_session.session_key) 53 >>> cache_session.exists(cache_session.session_key) 54 False 29 55 """ 30 31 from django.contrib.sessions.middleware import SessionWrapper32 56 33 57 if __name__ == '__main__': django/branches/newforms-admin/django/core/context_processors.py
r5440 r6371 14 14 Returns context variables required by apps that use Django's authentication 15 15 system. 16 17 If there is no 'user' attribute in the request, uses AnonymousUser (from 18 django.contrib.auth). 16 19 """ 20 if hasattr(request, 'user'): 21 user = request.user 22 else: 23 from django.contrib.auth.models import AnonymousUser 24 user = AnonymousUser() 17 25 return { 18 'user': request.user,19 'messages': request.user.get_and_delete_messages(),20 'perms': PermWrapper( request.user),26 'user': user, 27 'messages': user.get_and_delete_messages(), 28 'perms': PermWrapper(user), 21 29 } 22 30 django/branches/newforms-admin/django/core/handlers/modpython.py
r6342 r6371 43 43 44 44 def is_secure(self): 45 # Note: modpython 3.2.10+ has req.is_https(), but we need to support previous versions 46 return 'HTTPS' in self._req.subprocess_env and self._req.subprocess_env['HTTPS'] == 'on' 45 try: 46 return self._req.is_https() 47 except AttributeError: 48 # mod_python < 3.2.10 doesn't have req.is_https(). 49 return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1') 47 50 48 51 def _load_post_and_files(self): django/branches/newforms-admin/django/db/models/base.py
r6342 r6371 83 83 def _get_pk_val(self): 84 84 return getattr(self, self._meta.pk.attname) 85 86 def _set_pk_val(self, value): 87 return setattr(self, self._meta.pk.attname, value) 88 89 pk = property(_get_pk_val, _set_pk_val) 85 90 86 91 def __repr__(self): django/branches/newforms-admin/django/db/models/fields/__init__.py
r6342 r6371 879 879 validators.isValidIPAddress4(field_data, None) 880 880 881 def formfield(self, **kwargs): 882 defaults = {'form_class': forms.IPAddressField} 883 defaults.update(kwargs) 884 return super(IPAddressField, self).formfield(**defaults) 885 881 886 class NullBooleanField(Field): 882 887 empty_strings_allowed = False django/branches/newforms-admin/django/middleware/http.py
r5828 r6371 56 56 else: 57 57 # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs. 58 # Take just the first one. 59 real_ip = real_ip.split(",")[0] 58 # Take just the last one. 59 # See http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/ 60 real_ip = real_ip.split(",")[-1].strip() 60 61 request.META['REMOTE_ADDR'] = real_ip django/branches/newforms-admin/django/newforms/fields.py
r6342 r6371 27 27 'ChoiceField', 'NullBooleanField', 'MultipleChoiceField', 28 28 'ComboField', 'MultiValueField', 'FloatField', 'DecimalField', 29 'SplitDateTimeField', 29 'SplitDateTimeField', 'IPAddressField', 30 30 ) 31 31 … … 636 636 return datetime.datetime.combine(*data_list) 637 637 return None 638 639 ipv4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$') 640 641 class IPAddressField(RegexField): 642 def __init__(self, *args, **kwargs): 643 RegexField.__init__(self, ipv4_re, 644 error_message=ugettext(u'Enter a valid IPv4 address.'), 645 *args, **kwargs) django/branches/newforms-admin/django/newforms/forms.py
r6342 r6371 64 64 # class, not to the Form class. 65 65 def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 66 initial=None, error_class=ErrorList):66 initial=None, error_class=ErrorList, label_suffix=':'): 67 67 self.is_bound = data is not None or files is not None 68 68 self.data = data or {} … … 72 72 self.initial = initial or {} 73 73 self.error_class = error_class 74 self.label_suffix = label_suffix 74 75 self._errors = None # Stores the errors after clean() has been called. 75 76 … … 135 136 if bf.label: 136 137 label = escape(force_unicode(bf.label)) 137 # Only add a colon if the label does not end in punctuation. 138 if label[-1] not in ':?.!': 139 label += ':' 138 # Only add the suffix if the label does not end in punctuation. 139 if self.label_suffix: 140 if label[-1] not in ':?.!': 141 label += self.label_suffix 140 142 label = bf.label_tag(label) or '' 141 143 else: django/branches/newforms-admin/django/test/client.py
r6342 r6371 5 5 from django.conf import settings 6 6 from django.contrib.auth import authenticate, login 7 from django.contrib.sessions.models import Session8 from django.contrib.sessions.middleware import SessionWrapper9 7 from django.core.handlers.base import BaseHandler 10 8 from django.core.handlers.wsgi import WSGIRequest … … 133 131 "Obtain the current session variables" 134 132 if 'django.contrib.sessions' in settings.INSTALLED_APPS: 133 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 135 134 cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) 136 135 if cookie: 137 return SessionWrapper(cookie.value)136 return engine.SessionStore(cookie.value) 138 137 return {} 139 138 session = property(_session) … … 248 247 user = authenticate(**credentials) 249 248 if user and user.is_active and 'django.contrib.sessions' in settings.INSTALLED_APPS: 250 obj = Session.objects.get_new_session_object()249 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 251 250 252 251 # Create a fake request to store login details 253 252 request = HttpRequest() 254 request.session = SessionWrapper(obj.session_key)253 request.session = engine.SessionStore() 255 254 login(request, user) 256 255 257 256 # Set the cookie to represent the session 258 self.cookies[settings.SESSION_COOKIE_NAME] = obj.session_key257 self.cookies[settings.SESSION_COOKIE_NAME] = request.session.session_key 259 258 self.cookies[settings.SESSION_COOKIE_NAME]['max-age'] = None 260 259 self.cookies[settings.SESSION_COOKIE_NAME]['path'] = '/' … … 263 262 self.cookies[settings.SESSION_COOKIE_NAME]['expires'] = None 264 263 265 # Set the session values 266 Session.objects.save(obj.session_key, request.session._session, 267 datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)) 264 # Save the session values 265 request.session.save() 268 266 269 267 return True … … 276 274 Causes the authenticated user to be logged out. 277 275 """ 278 try: 279 Session.objects.get(session_key=self.cookies['sessionid'].value).delete() 280 except KeyError: 281 pass 282 276 session = __import__(settings.SESSION_ENGINE, {}, {}, ['']).SessionStore() 277 session.delete(session_key=self.cookies['sessionid'].value) 283 278 self.cookies = SimpleCookie() django/branches/newforms-admin/django/utils/datastructures.py
r6342 r6371 73 73 return zip(self.keyOrder, self.values()) 74 74 75 def iteritems(self): 76 for key in self.keyOrder: 77 yield key, dict.__getitem__(self, key) 78 75 79 def keys(self): 76 80 return self.keyOrder[:] 77 81 82 def iterkeys(self): 83 return iter(self.keyOrder) 84 78 85 def values(self): 79 86 return [dict.__getitem__(self, k) for k in self.keyOrder] 87 88 def itervalues(self): 89 for key in self.keyOrder: 90 yield dict.__getitem__(self, key) 80 91 81 92 def update(self, dict): … … 91 102 "Returns the value of the item at the given zero-based index." 92 103 return self[self.keyOrder[index]] 104 105 def insert(self, index, key, value): 106 "Inserts the key, value pair before the item with the given index." 107 if key in self.keyOrder: 108 n = self.keyOrder.index(key) 109 del self.keyOrder[n] 110 if n < index: index -= 1 111 self.keyOrder.insert(index, key) 112 dict.__setitem__(self, key, value) 93 113 94 114 def copy(self): django/branches/newforms-admin/django/utils/dateformat.py
r6342 r6371 167 167 def O(self): 168 168 "Difference to Greenwich time in hours; e.g. '+0200'" 169 tz = self.timezone.utcoffset(self.data)170 return u"%+03d%02d" % ( tz.seconds // 3600, (tz.seconds // 60) % 60)169 seconds = self.Z() 170 return u"%+03d%02d" % (seconds // 3600, (seconds // 60) % 60) 171 171 172 172 def r(self): django/branches/newforms-admin/django/utils/timesince.py
r5828 r6371 1 import datetime, math, time 1 import datetime 2 import time 3 2 4 from django.utils.tzinfo import LocalTimezone 3 5 from django.utils.translation import ungettext, ugettext … … 5 7 def timesince(d, now=None): 6 8 """ 7 Takes two datetime objects and returns the time between then and now 8 as a nicely formatted string, e.g "10 minutes" 9 Takes two datetime objects and returns the time between d and now 10 as a nicely formatted string, e.g. "10 minutes". If d occurs after now, 11 then "0 minutes" is returned. 12 13 Units used are years, months, weeks, days, hours, and minutes. 14 Seconds and microseconds are ignored. Up to two adjacent units will be 15 displayed. For example, "2 weeks, 3 days" and "1 year, 3 months" are 16 possible outputs, but "2 weeks, 3 hours" and "1 year, 5 days" are not. 17 9 18 Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since 10 19 """ … … 33 42 delta = now - (d - datetime.timedelta(0, 0, d.microsecond)) 34 43 since = delta.days * 24 * 60 * 60 + delta.seconds 44 if since <= 0: 45 # d is in the future compared to now, stop processing. 46 return u'0 ' + ugettext('minutes') 35 47 for i, (seconds, name) in enumerate(chunks): 36 48 count = since // seconds django/branches/newforms-admin/docs/apache_auth.txt
r6342 r6371 35 35 36 36 You'll need to ensure that ``mod_auth_basic`` and ``mod_authz_user`` 37 are loaded. These might be compiled static ly into Apache, or you might37 are loaded. These might be compiled statically into Apache, or you might 38 38 need to use ``LoadModule`` to load them dynamically (as shown in the 39 39 example at the bottom of this note). 40 40 41 41 You'll also need to insert configuration directives that prevent Apache 42 from trying to use other authentication modules. Dep nding on which other42 from trying to use other authentication modules. Depending on which other 43 43 authentication modules you have loaded, you might need one or more of 44 44 the following directives:: django/branches/newforms-admin/docs/django-admin.txt
r6342 r6371 646 646
