web/views/editforms.py
branchtls-sprint
changeset 1277 2eeef019e186
parent 1276 f213008fad2c
child 1285 d5ce82d65c2b
equal deleted inserted replaced
1276:f213008fad2c 1277:2eeef019e186
   184 
   184 
   185     @classmethod
   185     @classmethod
   186     def registered(cls, registry):
   186     def registered(cls, registry):
   187         """build class using descriptor at registration time"""
   187         """build class using descriptor at registration time"""
   188         super(AutomaticEntityForm, cls).registered(registry)
   188         super(AutomaticEntityForm, cls).registered(registry)
   189         cls.init_rtags_category()
   189         cls.init_rcategories()
   190         return cls
   190         return cls
   191         
   191         
   192     @classmethod
   192     @classmethod
   193     def init_rtags_category(cls):
   193     def init_rcategories(cls):
   194         """set default category tags for relations where it's not yet defined in
   194         """set default category tags for relations where it's not yet defined in
   195         the category relation tags
   195         the category relation tags
   196         """
   196         """
   197         for eschema in cls.schema.entities():
   197         for eschema in cls.schema.entities():
   198             for rschema, tschemas, role in eschema.relation_definitions(True):
   198             for rschema, tschemas, role in eschema.relation_definitions(True):
   315     def __init__(self, *args, **kwargs):
   315     def __init__(self, *args, **kwargs):
   316         super(AutomaticEntityForm, self).__init__(*args, **kwargs)
   316         super(AutomaticEntityForm, self).__init__(*args, **kwargs)
   317         if self.edited_entity.has_eid():
   317         if self.edited_entity.has_eid():
   318             self.edited_entity.complete()
   318             self.edited_entity.complete()
   319         for rschema, role in self.editable_attributes():
   319         for rschema, role in self.editable_attributes():
       
   320             try:
       
   321                 self.field_by_name(rschema.type, role)
       
   322                 continue # explicitly specified
       
   323             except FieldNotFound:
       
   324                 pass # has to be guessed
   320             wdgname = self.rwidgets.etype_rtag(self.edited_entity.id, rschema,
   325             wdgname = self.rwidgets.etype_rtag(self.edited_entity.id, rschema,
   321                                                role)
   326                                                role)
   322             if wdgname:
   327             if wdgname:
   323                 widget = getattr(formwidgets, wdgname)
   328                 widget = getattr(formwidgets, wdgname)
   324                 field = guess_field(self.edited_entity.__class__, rschema, role,
   329                 field = guess_field(self.edited_entity.__class__, rschema, role,