6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from warnings import warn |
9 from warnings import warn |
10 |
10 |
11 from logilab.common.deprecation import deprecated_function |
11 from logilab.common.deprecation import deprecated_function, obsolete |
12 from logilab.common.decorators import cached |
12 from logilab.common.decorators import cached |
13 |
13 |
14 from cubicweb import Unauthorized, typed_eid |
14 from cubicweb import Unauthorized, typed_eid |
15 from cubicweb.entity import Entity |
15 from cubicweb.entity import Entity |
16 from cubicweb.utils import dump_class |
16 from cubicweb.utils import dump_class |
247 else: |
247 else: |
248 tschema = rschema.subjects(cls.e_schema)[0] |
248 tschema = rschema.subjects(cls.e_schema)[0] |
249 wdg = widget(cls.vreg, tschema, rschema, cls, 'object') |
249 wdg = widget(cls.vreg, tschema, rschema, cls, 'object') |
250 return wdg |
250 return wdg |
251 |
251 |
252 @obsolete('use AutomaticEntityForm.relations_by_category') |
252 @obsolete('use EntityFieldsForm.subject_relation_vocabulary') |
|
253 def subject_relation_vocabulary(self, rtype, limit): |
|
254 from cubicweb.web.form import EntityFieldsForm |
|
255 return EntityFieldsForm(entity=self).subject_relation_vocabulary(rtype, limit) |
|
256 |
|
257 @obsolete('use EntityFieldsForm.object_relation_vocabulary') |
|
258 def object_relation_vocabulary(self, rtype, limit): |
|
259 from cubicweb.web.form import EntityFieldsForm |
|
260 return EntityFieldsForm(entity=self).object_relation_vocabulary(rtype, limit) |
|
261 |
|
262 @obsolete('use AutomaticEntityForm.[e]relations_by_category') |
253 def relations_by_category(self, categories=None, permission=None): |
263 def relations_by_category(self, categories=None, permission=None): |
254 from cubicweb.web.views.editform import AutomaticEntityForm |
264 from cubicweb.web.views.editforms import AutomaticEntityForm |
255 return AutomaticEntityForm.relations_by_category(entity, categories, permission) |
265 return AutomaticEntityForm.erelations_by_category(self, categories, permission) |
256 |
266 |
|
267 @obsolete('use AutomaticEntityForm.[e]srelations_by_category') |
257 def srelations_by_category(self, categories=None, permission=None): |
268 def srelations_by_category(self, categories=None, permission=None): |
258 result = [] |
269 from cubicweb.web.views.editforms import AutomaticEntityForm |
259 for rschema, ttypes, target in self.relations_by_category(categories, |
270 return AutomaticEntityForm.esrelations_by_category(self, categories, permission) |
260 permission): |
|
261 if rschema.is_final(): |
|
262 continue |
|
263 result.append( (rschema.display_name(self.req, target), rschema, target) ) |
|
264 return sorted(result) |
|
265 |
271 |
266 def _default_format(self): |
272 def _default_format(self): |
267 return self.req.property_value('ui.default-text-format') |
273 return self.req.property_value('ui.default-text-format') |
268 |
274 |
269 def attribute_values(self, attrname): |
275 def attribute_values(self, attrname): |