entity.py
branchtls-sprint
changeset 1734 e8673144bc74
parent 1721 694f6a50e138
child 1739 78b0819162a8
equal deleted inserted replaced
1733:94c36d679454 1734:e8673144bc74
    44 _MODE_TAGS = set(('link', 'create'))
    44 _MODE_TAGS = set(('link', 'create'))
    45 _CATEGORY_TAGS = set(('primary', 'secondary', 'generic', 'generated')) # , 'metadata'))
    45 _CATEGORY_TAGS = set(('primary', 'secondary', 'generic', 'generated')) # , 'metadata'))
    46 
    46 
    47 try:
    47 try:
    48     from cubicweb.web import formwidgets, uicfg
    48     from cubicweb.web import formwidgets, uicfg
    49     from cubicweb.web.views.editforms import AutomaticEntityForm
       
    50 
    49 
    51     def _dispatch_rtags(tags, rtype, role, stype, otype):
    50     def _dispatch_rtags(tags, rtype, role, stype, otype):
    52         for tag in tags:
    51         for tag in tags:
    53             if tag in _MODE_TAGS:
    52             if tag in _MODE_TAGS:
    54                 uicfg.rmode.tag_relation(stype, rtype, otype, tag, role)
    53                 uicfg.rmode.tag_relation(stype, rtype, otype, tag, role)
    58                 uicfg.rinlined.tag_relation(stype, rtype, otype, True, role)
    57                 uicfg.rinlined.tag_relation(stype, rtype, otype, True, role)
    59             else:
    58             else:
    60                 raise ValueError(tag)
    59                 raise ValueError(tag)
    61 
    60 
    62 except ImportError:
    61 except ImportError:
       
    62 
    63     _dispatch_rtags = None
    63     _dispatch_rtags = None
    64 
    64 
    65 def _get_etype(bases, classdict):
    65 def _get_etype(bases, classdict):
    66     try:
    66     try:
    67         return classdict['id']
    67         return classdict['id']
   126                         continue
   126                         continue
   127                     if wdgname == 'StringWidget':
   127                     if wdgname == 'StringWidget':
   128                         wdgname = 'TextInput'
   128                         wdgname = 'TextInput'
   129                     widget = getattr(formwidgets, wdgname)
   129                     widget = getattr(formwidgets, wdgname)
   130                     assert hasattr(widget, 'render')
   130                     assert hasattr(widget, 'render')
   131                     AutomaticEntityForm.rwidgets.tag_relation(
   131                     uicfg.rwidgets.tag_relation(
   132                         etype, rtype, '*', widget, tagged='subject')
   132                         etype, rtype, '*', widget, tagged='subject')
   133         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
   133         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
   134 
   134 
   135 
   135 
   136 class Entity(AppRsetObject, dict):
   136 class Entity(AppRsetObject, dict):