Changeset 7176
- Timestamp:
- 02/28/08 15:24:51 (4 months ago)
- Files:
-
- django/branches/gis (modified) (1 prop)
- django/branches/gis/AUTHORS (modified) (3 diffs)
- django/branches/gis/django/conf/global_settings.py (modified) (2 diffs)
- django/branches/gis/django/conf/locale/eu (copied) (copied from django/trunk/django/conf/locale/eu)
- django/branches/gis/django/conf/locale/eu/LC_MESSAGES (copied) (copied from django/trunk/django/conf/locale/eu/LC_MESSAGES)
- django/branches/gis/django/conf/locale/eu/LC_MESSAGES/djangojs.mo (modified) (1 prop)
- django/branches/gis/django/conf/locale/eu/LC_MESSAGES/django.mo (modified) (1 prop)
- django/branches/gis/django/conf/locale/ka (copied) (copied from django/trunk/django/conf/locale/ka)
- django/branches/gis/django/conf/locale/ka/LC_MESSAGES (copied) (copied from django/trunk/django/conf/locale/ka/LC_MESSAGES)
- django/branches/gis/django/conf/locale/ka/LC_MESSAGES/djangojs.mo (copied) (copied from django/trunk/django/conf/locale/ka/LC_MESSAGES/djangojs.mo)
- django/branches/gis/django/conf/locale/ka/LC_MESSAGES/djangojs.po (copied) (copied from django/trunk/django/conf/locale/ka/LC_MESSAGES/djangojs.po)
- django/branches/gis/django/conf/locale/ka/LC_MESSAGES/django.mo (copied) (copied from django/trunk/django/conf/locale/ka/LC_MESSAGES/django.mo)
- django/branches/gis/django/conf/locale/ka/LC_MESSAGES/django.po (copied) (copied from django/trunk/django/conf/locale/ka/LC_MESSAGES/django.po)
- django/branches/gis/django/contrib/admin/views/decorators.py (modified) (3 diffs)
- django/branches/gis/django/contrib/auth/decorators.py (modified) (2 diffs)
- django/branches/gis/django/contrib/databrowse/plugins/calendars.py (modified) (1 diff)
- django/branches/gis/django/contrib/databrowse/plugins/fieldchoices.py (modified) (1 diff)
- django/branches/gis/django/contrib/databrowse/views.py (modified) (1 diff)
- django/branches/gis/django/contrib/formtools/preview.py (modified) (1 diff)
- django/branches/gis/django/contrib/formtools/tests.py (modified) (2 diffs)
- django/branches/gis/django/contrib/humanize/templatetags/humanize.py (modified) (1 diff)
- django/branches/gis/django/contrib/localflavor/ar/forms.py (modified) (1 diff)
- django/branches/gis/django/contrib/localflavor/jp/forms.py (modified) (1 diff)
- django/branches/gis/django/contrib/sessions/models.py (modified) (1 diff)
- django/branches/gis/django/contrib/webdesign/tests.py (modified) (1 diff)
- django/branches/gis/django/core/handlers/base.py (modified) (1 diff)
- django/branches/gis/django/core/management/commands/loaddata.py (modified) (6 diffs)
- django/branches/gis/django/core/management/commands/sqlall.py (modified) (1 diff)
- django/branches/gis/django/core/serializers/json.py (modified) (1 diff)
- django/branches/gis/django/core/serializers/pyyaml.py (modified) (1 diff)
- django/branches/gis/django/db/backends/mysql/base.py (modified) (1 diff)
- django/branches/gis/django/db/backends/postgresql/operations.py (modified) (1 diff)
- django/branches/gis/django/db/models/base.py (modified) (3 diffs)
- django/branches/gis/django/db/models/fields/__init__.py (modified) (23 diffs)
- django/branches/gis/django/db/models/fields/related.py (modified) (2 diffs)
- django/branches/gis/django/http/__init__.py (modified) (2 diffs)
- django/branches/gis/django/newforms/forms.py (modified) (2 diffs)
- django/branches/gis/django/newforms/models.py (modified) (3 diffs)
- django/branches/gis/django/template/defaultfilters.py (modified) (2 diffs)
- django/branches/gis/django/test/client.py (modified) (1 diff)
- django/branches/gis/django/test/_doctest.py (modified) (1 diff)
- django/branches/gis/django/test/simple.py (modified) (1 diff)
- django/branches/gis/django/utils/datastructures.py (modified) (3 diffs)
- django/branches/gis/django/utils/decorators.py (modified) (2 diffs)
- django/branches/gis/django/utils/functional.py (modified) (4 diffs)
- django/branches/gis/django/views/decorators/cache.py (modified) (3 diffs)
- django/branches/gis/django/views/decorators/http.py (modified) (2 diffs)
- django/branches/gis/django/views/decorators/vary.py (modified) (3 diffs)
- django/branches/gis/docs/api_stability.txt (modified) (1 diff)
- django/branches/gis/docs/contenttypes.txt (modified) (2 diffs)
- django/branches/gis/docs/db-api.txt (modified) (1 diff)
- django/branches/gis/docs/distributions.txt (modified) (1 diff)
- django/branches/gis/docs/django-admin.txt (modified) (2 diffs)
- django/branches/gis/docs/faq.txt (modified) (1 diff)
- django/branches/gis/docs/install.txt (modified) (1 diff)
- django/branches/gis/docs/model-api.txt (modified) (4 diffs)
- django/branches/gis/docs/modelforms.txt (modified) (1 diff)
- django/branches/gis/docs/request_response.txt (modified) (1 diff)
- django/branches/gis/docs/serialization.txt (modified) (1 diff)
- django/branches/gis/docs/shortcuts.txt (modified) (1 diff)
- django/branches/gis/docs/templates_python.txt (modified) (2 diffs)
- django/branches/gis/docs/templates.txt (modified) (1 diff)
- django/branches/gis/docs/url_dispatch.txt (modified) (1 diff)
- django/branches/gis/extras/django_bash_completion (modified) (2 diffs)
- django/branches/gis/setup.py (modified) (2 diffs)
- django/branches/gis/tests/modeltests/basic/models.py (modified) (2 diffs)
- django/branches/gis/tests/modeltests/model_forms/models.py (modified) (2 diffs)
- django/branches/gis/tests/modeltests/mutually_referential/models.py (modified) (2 diffs)
- django/branches/gis/tests/modeltests/ordering/models.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/datastructures/tests.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/datatypes/models.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/decorators (copied) (copied from django/trunk/tests/regressiontests/decorators)
- django/branches/gis/tests/regressiontests/decorators/__init__.py (copied) (copied from django/trunk/tests/regressiontests/decorators/__init__.py)
- django/branches/gis/tests/regressiontests/decorators/models.py (copied) (copied from django/trunk/tests/regressiontests/decorators/models.py)
- django/branches/gis/tests/regressiontests/decorators/tests.py (copied) (copied from django/trunk/tests/regressiontests/decorators/tests.py)
- django/branches/gis/tests/regressiontests/fixtures_regress/fixtures/absolute.json (copied) (copied from django/trunk/tests/regressiontests/fixtures_regress/fixtures/absolute.json)
- django/branches/gis/tests/regressiontests/fixtures_regress/models.py (modified) (3 diffs)
- django/branches/gis/tests/regressiontests/i18n/misc.py (modified) (3 diffs)
- django/branches/gis/tests/regressiontests/string_lookup/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis
- Property svnmerge-integrated changed from /django/trunk:1-7102 to /django/trunk:1-7175
django/branches/gis/AUTHORS
r7103 r7176 57 57 Jökull Sólberg Auðunsson <jokullsolberg@gmail.com> 58 58 Arthur <avandorp@gmail.com> 59 David Avsajanishvili <avsd05@gmail.com> 59 60 axiak@mit.edu 60 61 Jiri Barton … … 71 72 Andrew Brehaut <http://brehaut.net/blog> 72 73 brut.alll@gmail.com 74 btoll@bestweb.net 73 75 Jonathan Buchanan <jonathan.buchanan@gmail.com> 74 76 Can Burak Ãilingir <canburak@cs.bilgi.edu.tr> … … 169 171 Jason Huggins <http://www.jrandolph.com/blog/> 170 172 Hyun Mi Ae 173 Ibon <ibonso@gmail.com> 171 174 Tom Insam 172 175 Baurzhan Ismagulov <ibr@radix50.net> django/branches/gis/django/conf/global_settings.py
r7103 r7176 49 49 ('es', gettext_noop('Spanish')), 50 50 ('es-ar', gettext_noop('Argentinean Spanish')), 51 ('eu', gettext_noop('Basque')), 51 52 ('fa', gettext_noop('Persian')), 52 53 ('fi', gettext_noop('Finnish')), 53 54 ('fr', gettext_noop('French')), 54 ('ga', gettext_noop(' Gaeilge')),55 ('ga', gettext_noop('Irish')), 55 56 ('gl', gettext_noop('Galician')), 56 57 ('hu', gettext_noop('Hungarian')), … … 60 61 ('it', gettext_noop('Italian')), 61 62 ('ja', gettext_noop('Japanese')), 63 ('ka', gettext_noop('Georgian')), 62 64 ('ko', gettext_noop('Korean')), 63 65 ('km', gettext_noop('Khmer')), django/branches/gis/django/conf/locale/eu/LC_MESSAGES/djangojs.mo
- Property svn:mime-type set to application/octet-stream
django/branches/gis/django/conf/locale/eu/LC_MESSAGES/django.mo
- Property svn:mime-type set to application/octet-stream
django/branches/gis/django/contrib/admin/views/decorators.py
r6672 r7176 1 import base64 2 import md5 3 import cPickle as pickle 4 try: 5 from functools import wraps 6 except ImportError: 7 from django.utils.functional import wraps # Python 2.3, 2.4 fallback. 8 1 9 from django import http, template 2 10 from django.conf import settings … … 6 14 from django.utils.translation import ugettext_lazy, ugettext as _ 7 15 from django.utils.safestring import mark_safe 8 import base64, datetime, md59 import cPickle as pickle10 16 11 17 ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") … … 105 111 return _display_login_form(request, ERROR_MESSAGE) 106 112 107 return _checklogin113 return wraps(view_func)(_checklogin) django/branches/gis/django/contrib/auth/decorators.py
r6672 r7176 1 try: 2 from functools import wraps, update_wrapper 3 except ImportError: 4 from django.utils.functional import wraps, update_wrapper # Python 2.3, 2.4 fallback. 5 1 6 from django.contrib.auth import REDIRECT_FIELD_NAME 2 7 from django.http import HttpResponseRedirect … … 52 57 self.login_url = login_url 53 58 self.redirect_field_name = redirect_field_name 54 self.__name__ = view_func.__name__59 update_wrapper(self, view_func) 55 60 56 61 def __get__(self, obj, cls=None): django/branches/gis/django/contrib/databrowse/plugins/calendars.py
r6672 r7176 9 9 from django.utils.safestring import mark_safe 10 10 from django.views.generic import date_based 11 import datetime12 import time13 11 14 12 class CalendarPlugin(DatabrowsePlugin): django/branches/gis/django/contrib/databrowse/plugins/fieldchoices.py
r6672 r7176 8 8 from django.utils.safestring import mark_safe 9 9 from django.views.generic import date_based 10 import datetime11 import time12 10 import urllib 13 11 django/branches/gis/django/contrib/databrowse/views.py
r5492 r7176 3 3 from django.shortcuts import render_to_response 4 4 from django.contrib.databrowse.datastructures import EasyModel, EasyChoice 5 import datetime6 import time7 5 8 6 ########### django/branches/gis/django/contrib/formtools/preview.py
r6815 r7176 4 4 5 5 from django.conf import settings 6 from django.core.exceptions import ImproperlyConfigured7 6 from django.http import Http404 8 7 from django.shortcuts import render_to_response django/branches/gis/django/contrib/formtools/tests.py
r6815 r7176 4 4 from django.conf import settings 5 5 from django.test import TestCase 6 from django.test.client import Client7 8 6 9 7 success_string = "Done was called!" … … 89 87 self.assertEqual(response.content, success_string) 90 88 91 92 if __name__ == '__main__':93 unittest.main()django/branches/gis/django/contrib/humanize/templatetags/humanize.py
r6672 r7176 3 3 from django import template 4 4 from django.template import defaultfilters 5 from django.conf import settings 6 from datetime import date, timedelta 5 from datetime import date 7 6 import re 8 7 django/branches/gis/django/contrib/localflavor/ar/forms.py
r7103 r7176 8 8 from django.utils.encoding import smart_unicode 9 9 from django.utils.translation import ugettext 10 import re11 10 12 11 class ARProvinceSelect(Select): django/branches/gis/django/contrib/localflavor/jp/forms.py
r6990 r7176 7 7 from django.utils.translation import ugettext 8 8 from django.newforms.fields import RegexField, Select 9 10 import re11 9 12 10 class JPPostalCodeField(RegexField): django/branches/gis/django/contrib/sessions/models.py
r6920 r7176 1 import os2 import sys3 import time4 import datetime5 1 import base64 6 2 import md5 7 import random8 3 import cPickle as pickle 9 4 django/branches/gis/django/contrib/webdesign/tests.py
r6394 r7176 15 15 16 16 from django.contrib.webdesign.lorem_ipsum import * 17 import datetime18 17 19 18 if __name__ == '__main__': django/branches/gis/django/core/handlers/base.py
r7103 r7176 110 110 return http.HttpResponseForbidden('<h1>Permission denied</h1>') 111 111 except SystemExit: 112 pass # See http://code.djangoproject.com/ticket/1023 112 # Allow sys.exit() to actually exit. See tickets #1023 and #4701 113 raise 113 114 except: # Handle everything else, including SuspiciousOperation, etc. 114 115 # Get the exception info now, in case another exception is thrown later. django/branches/gis/django/core/management/commands/loaddata.py
r7044 r7176 31 31 32 32 # Keep a count of the installed objects and fixtures 33 count = [0, 0] 33 fixture_count = 0 34 object_count = 0 34 35 models = set() 35 36 … … 66 67 print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format) 67 68 68 for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']: 69 if os.path.isabs(fixture_name): 70 fixture_dirs = [fixture_name] 71 else: 72 fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + [''] 73 74 for fixture_dir in fixture_dirs: 69 75 if verbosity > 1: 70 76 print "Checking %s for fixtures..." % humanize(fixture_dir) … … 87 93 return 88 94 else: 89 count[1]+= 195 fixture_count += 1 90 96 if verbosity > 0: 91 97 print "Installing %s fixture '%s' from %s." % \ … … 94 100 objects = serializers.deserialize(format, fixture) 95 101 for obj in objects: 96 count[0]+= 1102 object_count += 1 97 103 models.add(obj.object.__class__) 98 104 obj.save() … … 114 120 (format, fixture_name, humanize(fixture_dir)) 115 121 116 if count[0]> 0:122 if object_count > 0: 117 123 sequence_sql = connection.ops.sequence_reset_sql(self.style, models) 118 124 if sequence_sql: … … 125 131 transaction.leave_transaction_management() 126 132 127 if count[0]== 0:133 if object_count == 0: 128 134 if verbosity >= 2: 129 135 print "No fixtures found." 130 136 else: 131 137 if verbosity > 0: 132 print "Installed %d object(s) from %d fixture(s)" % tuple(count)138 print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count) django/branches/gis/django/core/management/commands/sqlall.py
r6018 r7176 2 2 3 3 class Command(AppCommand): 4 help = "Prints the CREATE TABLE, initial-dataand CREATE INDEX SQL statements for the given model module name(s)."4 help = "Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s)." 5 5 6 6 output_transaction = True django/branches/gis/django/core/serializers/json.py
r6990 r7176 5 5 import datetime 6 6 from django.utils import simplejson 7 from django.utils.simplejson import decoder8 7 from django.core.serializers.python import Serializer as PythonSerializer 9 8 from django.core.serializers.python import Deserializer as PythonDeserializer django/branches/gis/django/core/serializers/pyyaml.py
r6990 r7176 5 5 """ 6 6 7 import datetime8 7 from django.db import models 9 8 from django.core.serializers.python import Serializer as PythonSerializer django/branches/gis/django/db/backends/mysql/base.py
r6672 r7176 22 22 from MySQLdb.converters import conversions 23 23 from MySQLdb.constants import FIELD_TYPE 24 import types25 24 import re 26 25 django/branches/gis/django/db/backends/postgresql/operations.py
r6525 r7176 27 27 def deferrable_sql(self): 28 28 return " DEFERRABLE INITIALLY DEFERRED" 29 30 def field_cast_sql(self, db_type): 31 if db_type == 'inet': 32 return 'HOST(%s)' 33 return '%s' 29 34 30 35 def last_insert_id(self, cursor, table_name, pk_name): django/branches/gis/django/db/models/base.py
r7103 r7176 42 42 # Build complete list of parents 43 43 for base in parents: 44 if base is not Model: 44 # Things without _meta aren't functional models, so they're 45 # uninteresting parents. 46 if hasattr(base, '_meta'): 45 47 new_class._meta.parents.append(base) 46 48 new_class._meta.parents.extend(base._meta.parents) … … 134 136 return not self.__eq__(other) 135 137 138 def __hash__(self): 139 return hash(self._get_pk_val()) 140 136 141 def __init__(self, *args, **kwargs): 137 142 dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs) … … 140 145 # overrides it. It should be one or the other; don't duplicate the work 141 146 # The reason for the kwargs check is that standard iterator passes in by 142 # args, and nstantiation for iteration is 33% faster.147 # args, and instantiation for iteration is 33% faster. 143 148 args_len = len(args) 144 149 if args_len > len(self._meta.fields): django/branches/gis/django/db/models/fields/__init__.py
r7044 r7176 229 229 except ValueError: 230 230 raise ValueError("The __year lookup type requires an integer argument") 231 return ['%s-01-01 00:00:00' % value, '%s-12-31 23:59:59.999999' % value] 231 if settings.DATABASE_ENGINE == 'sqlite3': 232 first = '%s-01-01' 233 else: 234 first = '%s-01-01 00:00:00' 235 return [first % value, '%s-12-31 23:59:59.999999' % value] 232 236 raise TypeError("Field has invalid lookup: %s" % lookup_type) 233 237 … … 452 456 Field.__init__(self, *args, **kwargs) 453 457 458 def get_internal_type(self): 459 return "BooleanField" 460 454 461 def to_python(self, value): 455 462 if value in (True, False): return value … … 469 476 def get_manipulator_field_objs(self): 470 477 return [oldforms.TextField] 478 479 def get_internal_type(self): 480 return "CharField" 471 481 472 482 def to_python(self, value): … … 499 509 kwargs['blank'] = True 500 510 Field.__init__(self, verbose_name, name, **kwargs) 511 512 def get_internal_type(self): 513 return "DateField" 501 514 502 515 def to_python(self, value): … … 569 582 570 583 class DateTimeField(DateField): 584 def get_internal_type(self): 585 return "DateTimeField" 586 571 587 def to_python(self, value): 572 588 if value is None: … … 639 655 Field.__init__(self, verbose_name, name, **kwargs) 640 656 657 def get_internal_type(self): 658 return "DecimalField" 659 641 660 def to_python(self, value): 642 661 if value is None: … … 698 717 CharField.__init__(self, *args, **kwargs) 699 718 700 def get_internal_type(self):701 return "CharField"702 703 719 def get_manipulator_field_objs(self): 704 720 return [oldforms.EmailField] … … 717 733 kwargs['max_length'] = kwargs.get('max_length', 100) 718 734 Field.__init__(self, verbose_name, name, **kwargs) 735 736 def get_internal_type(self): 737 return "FileField" 719 738 720 739 def get_db_prep_save(self, value): … … 827 846 return [curry(oldforms.FilePathField, path=self.path, match=self.match, recursive=self.recursive)] 828 847 848 def get_internal_type(self): 849 return "FilePathField" 850 829 851 class FloatField(Field): 830 852 empty_strings_allowed = False … … 832 854 def get_manipulator_field_objs(self): 833 855 return [oldforms.FloatField] 856 857 def get_internal_type(self): 858 return "FloatField" 834 859 835 860 def formfield(self, **kwargs): … … 854 879 if not self.height_field: 855 880 setattr(cls, 'get_%s_height' % self.name, curry(cls._get_FIELD_height, field=self)) 881 882 def get_internal_type(self): 883 return "ImageField" 856 884 857 885 def save_file(self, new_data, new_object, original_object, change, rel, save=True): … … 877 905 return [oldforms.IntegerField] 878 906 907 def get_internal_type(self): 908 return "IntegerField" 909 879 910 def formfield(self, **kwargs): 880 911 defaults = {'form_class': forms.IntegerField} … … 891 922 return [oldforms.IPAddressField] 892 923 924 def get_internal_type(self): 925 return "IPAddressField" 926 893 927 def validate(self, field_data, all_data): 894 928 validators.isValidIPAddress4(field_data, None) … … 904 938 kwargs['null'] = True 905 939 Field.__init__(self, *args, **kwargs) 940 941 def get_internal_type(self): 942 return "NullBooleanField" 906 943 907 944 def to_python(self, value): … … 924 961 return [oldforms.PhoneNumberField] 925 962 963 def get_internal_type(self): 964 return "PhoneNumberField" 965 926 966 def validate(self, field_data, all_data): 927 967 validators.isValidPhone(field_data, all_data) … … 937 977 return [oldforms.PositiveIntegerField] 938 978 979 def get_internal_type(self): 980 return "PositiveIntegerField" 981 939 982 def formfield(self, **kwargs): 940 983 defaults = {'min_value': 0} … … 945 988 def get_manipulator_field_objs(self): 946 989 return [oldforms.PositiveSmallIntegerField] 990 991 def get_internal_type(self): 992 return "PositiveSmallIntegerField" 947 993 948 994 def formfield(self, **kwargs): … … 960 1006 super(SlugField, self).__init__(*args, **kwargs) 961 1007 1008 def get_internal_type(self): 1009 return "SlugField" 1010 962 1011 class SmallIntegerField(IntegerField): 963 1012 def get_manipulator_field_objs(self): 964 1013 return [oldforms.SmallIntegerField] 965 1014 1015 def get_internal_type(self): 1016 return "SmallIntegerField" 1017 966 1018 class TextField(Field): 967 1019 def get_manipulator_field_objs(self): 968 1020 return [oldforms.LargeTextField] 1021 1022 def get_internal_type(self): 1023 return "TextField" 969 1024 970 1025 def formfield(self, **kwargs): … … 980 1035 kwargs['editable'] = False 981 1036 Field.__init__(self, verbose_name, name, **kwargs) 1037 1038 def get_internal_type(self): 1039 return "TimeField" 982 1040 983 1041 def get_db_prep_lookup(self, lookup_type, value): … … 1045 1103 return [oldforms.URLField] 1046 1104 1047 def get_internal_type(self):1048 return "CharField"1049 1050 1105 def formfield(self, **kwargs): 1051 1106 defaults = {'form_class': forms.URLField, 'verify_exists': self.verify_exists} … … 1056 1111 def get_manipulator_field_objs(self): 1057 1112 return [oldforms.USStateField] 1113 1114 def get_internal_type(self): 1115 return "USStateField" 1058 1116 1059 1117 def formfield(self, **kwargs): … … 1067 1125 self.schema_path = schema_path 1068 1126 Field.__init__(self, verbose_name, name, **kwargs) 1069 1070 def get_internal_type(self):1071 return "TextField"1072 1127 1073 1128 def get_manipulator_field_objs(self): … … 1081 1136 IntegerField.__init__(self, **kwargs ) 1082 1137 1083 def get_internal_type(self):1084 return "IntegerField"1085 1086 1138 def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True): 1087 1139 return [oldforms.HiddenField(name_prefix + self.name)] django/branches/gis/django/db/models/fields/related.py
r6018 r7176 24 24 pending_lookups = {} 25 25 26 def add_lookup(rel_cls, field): 27 name = field.rel.to 28 module = rel_cls.__module__ 29 key = (module, name) 30 # Has the model already been loaded? 31 # If so, resolve the string reference right away 32 model = get_model(rel_cls._meta.app_label, field.rel.to, False) 26 def add_lazy_relation(cls, field, relation): 27 """ 28 Adds a lookup on ``cls`` when a related field is defined using a string, 29 i.e.:: 30 31 class MyModel(Model): 32 fk = ForeignKey("AnotherModel") 33 34 This string can be: 35 36 * RECURSIVE_RELATIONSHIP_CONSTANT (i.e. "self") to indicate a recursive 37 relation. 38 39 * The name of a model (i.e "AnotherModel") to indicate another model in 40 the same app. 41 42 * An app-label and model name (i.e. "someapp.AnotherModel") to indicate 43 another model in a different app. 44 45 If the other model hasn't yet been loaded -- almost a given if you're using 46 lazy relationships -- then the relation won't be set up until the 47 class_prepared signal fires at the end of model initialization. 48 """ 49 # Check for recursive relations 50 if relation == RECURSIVE_RELATIONSHIP_CONSTANT: 51 app_label = cls._meta.app_label 52 model_name = cls.__name__ 53 54 else: 55 # Look for an "app.Model" relation 56 try: 57 app_label, model_name = relation.split(".") 58 except ValueError: 59 # If we can't split, assume a model in current app 60 app_label = cls._meta.app_label 61 model_name = relation 62 63 # Try to look up the related model, and if it's already loaded resolve the 64 # string right away. If get_model returns None, it means that the related 65 # model isn't loaded yet, so we need to pend the relation until the class 66 # is prepared. 67 model = get_model(app_label, model_name, False) 33 68 if model: 34 69 field.rel.to = model 35 field.do_related_class(model, rel_cls)70 field.do_related_class(model, cls) 36 71 else: 37 # Mark the related field for later lookup 38 pending_lookups.setdefault(key, []).append((rel_cls, field)) 39 72 key = (app_label, model_name) 73 value = (cls, field) 74 pending_lookups.setdefault(key, []).append(value) 75 40 76 def do_pending_lookups(sender): 41 other_cls = sender 42 key = (other_cls.__module__, other_cls.__name__) 43 for rel_cls, field in pending_lookups.setdefault(key, []): 44 field.rel.to = other_cls 45 field.do_related_class(other_cls, rel_cls) 77 """ 78 Handle any pending relations to the sending model. Sent from class_prepared. 79 """ 80 key = (sender._meta.app_label, sender.__name__) 81 for cls, field in pending_lookups.pop(key, []): 82 field.rel.to = sender 83 field.do_related_class(sender, cls) 46 84 47 85 dispatcher.connect(do_pending_lookups, signal=signals.class_prepared) … … 67 105 other = self.rel.to 68 106 if isinstance(other, basestring): 69 if other == RECURSIVE_RELATIONSHIP_CONSTANT: 70 self.rel.to = cls.__name__ 71 add_lookup(cls, self) 107 add_lazy_relation(cls, self, other) 72 108 else: 73 109 self.do_related_class(other, cls) django/branches/gis/django/http/__init__.py
r6990 r7176 172 172 return result 173 173 174 def __deepcopy__(self, memo ={}):174 def __deepcopy__(self, memo): 175 175 import copy 176 176 result = self.__class__('', mutable=True) … … 224 224 def copy(self): 225 225 "Returns a mutable copy of this object." 226 return self.__deepcopy__( )226 return self.__deepcopy__({}) 227 227 228 228 def urlencode(self): django/branches/gis/django/newforms/forms.py
r7044 r7176 22 22 name = name[0].upper() + name[1:] 23 23 return name.replace('_', ' ') 24 25 def get_declared_fields(bases, attrs, with_base_fields=True): 26 """ 27 Create a list of form field instances from the passed in 'attrs', p
