Django

Code

Changeset 7504

Show
Ignore:
Timestamp:
04/28/08 20:19:42 (2 months ago)
Author:
mtredinnick
Message:

Undo [7474]. I didn't think it through nearly carefully enough.

This means that all model construction now goes through the init() method
again.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/base.py

    r7477 r7504  
    238238        dispatcher.send(signal=signals.post_init, sender=self.__class__, instance=self) 
    239239 
    240     def from_sequence(cls, values): 
    241         """ 
    242         An alternate class constructor, primarily for internal use. 
    243  
    244         Creates a model instance from a sequence of values (which corresponds 
    245         to all the non-many-to-many fields in creation order. If there are more 
    246         fields than values, the remaining (final) fields are given their 
    247         default values. 
    248  
    249         ForeignKey fields can only be initialised using id values, not 
    250         instances, in this method. 
    251         """ 
    252         dispatcher.send(signal=signals.pre_init, sender=cls, args=values, 
    253                 kwargs={}) 
    254         obj = Empty() 
    255         obj.__class__ = cls 
    256         field_iter = iter(obj._meta.fields) 
    257         for val, field in izip(values, field_iter): 
    258             setattr(obj, field.attname, val) 
    259         for field in field_iter: 
    260             setattr(obj, field.attname, field.get_default()) 
    261         dispatcher.send(signal=signals.post_init, sender=cls, instance=obj) 
    262         return obj 
    263  
    264     from_sequence = classmethod(from_sequence) 
    265  
    266240    def __repr__(self): 
    267241        return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self))) 
  • django/trunk/django/db/models/query.py

    r7499 r7504  
    165165                        max_depth, requested=requested) 
    166166            else: 
    167                 obj = self.model.from_sequence(row[index_start:]) 
     167                obj = self.model(*row[index_start:]) 
    168168            for i, k in enumerate(extra_select): 
    169169                setattr(obj, k, row[i]) 
     
    656656    restricted = requested is not None 
    657657    index_end = index_start + len(klass._meta.fields) 
    658     obj = klass.from_sequence(row[index_start:index_end]) 
     658    obj = klass(*row[index_start:index_end]) 
    659659    for f in klass._meta.fields: 
    660660        if (not f.rel or (not restricted and f.null) or