Changeset 7137
- Timestamp:
- 02/19/08 20:00:20 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/base.py
r7136 r7137 35 35 36 36 # Create the class. 37 new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')})37 module = attrs.pop('__module__') 38 38 meta = attrs.pop('Meta', None) 39 # FIXME: Promote Meta to a newstyle class before attaching it to the 40 # model. 41 ## if meta: 42 ## new_class.Meta = meta 39 new_class = type.__new__(cls, name, bases, {'__module__': module}) 43 40 new_class.add_to_class('_meta', Options(meta)) 44 # FIXME: Need to be smarter here. Exception is an old-style class in45 # Python <= 2.4, new-style in Python 2.5+. This construction is only46 # really correct for old-style classes.47 new_class.add_to_class('DoesNotExist', types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {}))48 new_class.add_to_class('MultipleObjectsReturned', types.ClassType('MultipleObjectsReturned', (MultipleObjectsReturned, ), {}))41 new_class.add_to_class('DoesNotExist', 42 subclass_exception('DoesNotExist', ObjectDoesNotExist, module)) 43 new_class.add_to_class('MultipleObjectsReturned', 44 subclass_exception('MultipleObjectsReturned', 45 MultipleObjectsReturned, module)) 49 46 50 47 # Do the appropriate setup for any model parents. … … 489 486 def get_absolute_url(opts, func, self, *args, **kwargs): 490 487 return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs) 488 489 ######## 490 # MISC # 491 ######## 492 493 if sys.version_info < (2, 5): 494 # Prior to Python 2.5, Exception was an old-style class 495 def subclass_exception(name, parent, unused): 496 return types.ClassType(name, (parent,), {}) 497 498 else: 499 def subclass_exception(name, parent, module): 500 return type(name, (parent,), {'__module__': module}) 501 django/branches/queryset-refactor/django/db/models/options.py
r7126 r7137 1 1 import re 2 2 from bisect import bisect 3 try: 4 set 5 except NameError: 6 from sets import Set as set # Python 2.3 fallback 3 7 4 8 from django.conf import settings … … 408 412 determining if something is an ancestor, regardless of lineage. 409 413 """ 410 # FIXME: Fix model hashing and then use a Set here. 411 result = [] 414 result = set() 412 415 for parent in self.parents: 413 result.a ppend(parent)414 result. extend(parent._meta.get_parent_list())416 result.add(parent) 417 result.update(parent._meta.get_parent_list()) 415 418 return result 416 419
