Changeset 2032
- Timestamp:
- 01/17/06 11:23:18 (3 years ago)
- Files:
-
- django/branches/magic-removal/django/db/models/fields/__init__.py (modified) (3 diffs)
- django/branches/magic-removal/django/db/models/fields/related.py (modified) (8 diffs)
- django/branches/magic-removal/django/db/models/__init__.py (modified) (2 diffs)
- django/branches/magic-removal/django/db/models/manipulators.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/db/models/fields/__init__.py
r2028 r2032 388 388 return value 389 389 390 def contribute_to_class(self, cls, name):390 def contribute_to_class(self, cls, name): 391 391 super(DateField,self).contribute_to_class(cls, name) 392 392 if not self.null: … … 712 712 713 713 def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True): 714 return [forms.HiddenField(name_prefix + self.name) ]714 return [forms.HiddenField(name_prefix + self.name)] 715 715 716 716 class BoundFieldLine(object): … … 762 762 763 763 def __repr__(self): 764 return "FieldSet: (%s,%s)" % (self.name, self.field_lines)764 return "FieldSet: (%s, %s)" % (self.name, self.field_lines) 765 765 766 766 def bind(self, field_mapping, original, bound_field_set_class=BoundFieldSet): django/branches/magic-removal/django/db/models/fields/related.py
r1956 r2032 24 24 other_cls = sender 25 25 key = (other_cls.__module__, other_cls.__name__) 26 for rel_cls, field in pending_lookups.setdefault(key, []):26 for rel_cls, field in pending_lookups.setdefault(key, []): 27 27 field.rel.to = other_cls 28 28 field.do_related_class(other_cls, rel_cls) … … 101 101 Field.__init__(self, **kwargs) 102 102 103 self.db_index = True 104 103 105 for name in ('num_in_admin', 'min_num_in_admin', 'max_num_in_admin', 'num_extra_on_change'): 104 106 if name in kwargs: 105 107 self.deprecated_args.append(name) 106 108 107 if not self.db_index:108 self.db_index = True109 110 109 def prepare_field_objs_and_params(self, manipulator, name_prefix): 111 params = {'validator_list': self.validator_list[:]} 112 113 params['member_name'] = name_prefix + self.attname 110 params = {'validator_list': self.validator_list[:], 'member_name': name_prefix + self.attname} 114 111 if self.rel.raw_id_admin: 115 112 field_objs = self.get_manipulator_field_objs() … … 125 122 field_objs = [forms.SelectField] 126 123 params['choices'] = self.get_choices_default() 127 return (field_objs, params)124 return field_objs, params 128 125 129 126 def get_manipulator_field_objs(self): … … 193 190 IntegerField.__init__(self, **kwargs) 194 191 192 self.db_index = True 193 195 194 for name in ('num_in_admin'): 196 195 if name in kwargs: 197 196 self.deprecated_args.append(name) 198 199 if not self.db_index:200 self.db_index = True201 197 202 198 def contribute_to_related_class(self, cls, related): … … 225 221 self.deprecated_args.append(name) 226 222 227 228 223 if self.rel.raw_id_admin: 229 msg = gettext_lazy(' Separate multiple IDs with commas.') 230 else: 231 msg = gettext_lazy(' Hold down "Control", or "Command" on a Mac, to select more than one.') 232 self.help_text = string_concat( self.help_text , msg ) 233 224 msg = gettext_lazy('Separate multiple IDs with commas.') 225 else: 226 msg = gettext_lazy('Hold down "Control", or "Command" on a Mac, to select more than one.') 227 self.help_text = string_concat(self.help_text, msg) 234 228 235 229 def get_manipulator_field_objs(self): … … 294 288 def contribute_to_related_class(self, cls, related): 295 289 rel_obj_name = related.get_method_name_part() 296 setattr(cls, 'get_%s' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_object', rel_class=related.model , rel_field=related.field))290 setattr(cls, 'get_%s' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_object', rel_class=related.model, rel_field=related.field)) 297 291 setattr(cls, 'get_%s_count' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_count', rel_class=related.model, rel_field=related.field)) 298 292 setattr(cls, 'get_%s_list' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_list', rel_class=related.model, rel_field=related.field)) … … 307 301 pass 308 302 309 class ManyToManyFieldNew(RelatedField):310 def __init__(self, to, **kwargs):311 self.to = to312 self.from_ = None313 self.rel = self314 self.edit_inline = False315 316 def set_attributes_from_rel(self):317 pass318 319 def contribute_to_class(self, cls, name):320 self.from_ = cls321 self.name = name322 super(ManyToManyFieldNew, self).contribute_to_class(cls, name)323 324 325 def contribute_to_related_class(self, cls, name):326 #Now we know both classes exist.327 self.to = cls328 # We need to wait until the class we were in was fully defined329 dispatcher.connect(self.from_prepared, signal=signals.class_prepared, sender=self.from_)330 331 def from_prepared(self):332 from django.db.models.base import Model333 334 class M2M(Model):335 __module__ = self.from_.__module__336 337 id_to = self.from_._meta.db_table338 id_from = self.to._meta.db_table339 340 M2M.add_to_class(id_from, ForeignKey(to=self.from_))341 M2M.add_to_class(id_to, ForeignKey(to=self.to))342 M2M._meta.db_table = '%s_%s' % (self.from_._meta.db_table, self.name)343 M2M._meta.unique_together = ((id_to, id_from),)344 M2M.__name__ = "M2M_%s_%s_%s" % (self.name, self.from_.__name__, self.to.__name__)345 346 303 class ManyToOne: 347 304 def __init__(self, to, field_name, edit_inline=False, … … 350 307 to._meta 351 308 except AttributeError: 352 assert isinstance(to, basestring) , "'to' must be either a model, a model name or the string %r" % RECURSIVE_RELATIONSHIP_CONSTANT309 assert isinstance(to, basestring), "'to' must be either a model, a model name or the string %r" % RECURSIVE_RELATIONSHIP_CONSTANT 353 310 self.to, self.field_name = to, field_name 354 311 self.edit_inline = edit_inline django/branches/magic-removal/django/db/models/__init__.py
r2017 r2032 27 27 if hasattr(mod, '__all__'): 28 28 for name in mod.__all__: 29 sub_mod = __import__("%s.%s" % (mod.__name__, name), '', '',[''])29 sub_mod = __import__("%s.%s" % (mod.__name__, name), '', '', ['']) 30 30 get_models_helper(sub_mod, seen_models) 31 31 … … 34 34 comps = app_name.split('.') 35 35 if app_label == comps[-1]: 36 app_models = __import__('%s.models' % app_name , '','',[''])36 app_models = __import__('%s.models' % app_name, '', '', ['']) 37 37 return app_models 38 38 raise ImproperlyConfigured, "App with label %s could not be found" % app_label django/branches/magic-removal/django/db/models/manipulators.py
r1956 r2032 244 244 # 245 245 # # Save inline edited objects 246 # self._fill_related_objects(expanded_data, SaveHelper)246 # self._fill_related_objects(expanded_data, SaveHelper) 247 247 # 248 248 # return new_object … … 437 437 438 438 prefix = '%s%s.' % (self.name_prefix, index ) 439 child_manip = man_class(self.follow, self.name_parts + ( str(index), ))439 child_manip = man_class(self.follow, self.name_parts + (str(index),)) 440 440 441 441 self[index] = child_manip
