241 |
241 |
242 @property |
242 @property |
243 def schema(self): |
243 def schema(self): |
244 return self.vreg.schema |
244 return self.vreg.schema |
245 |
245 |
246 @deprecated('[3.6] select object, then use obj.render()') |
|
247 def render(self, __oid, req, __fallback_oid=None, rset=None, initargs=None, |
|
248 **kwargs): |
|
249 """Select object with the given id (`__oid`) then render it. If the |
|
250 object isn't selectable, try to select fallback object if |
|
251 `__fallback_oid` is specified. |
|
252 |
|
253 If specified `initargs` is expected to be a dictionnary containing |
|
254 arguments that should be given to selection (hence to object's __init__ |
|
255 as well), but not to render(). Other arbitrary keyword arguments will be |
|
256 given to selection *and* to render(), and so should be handled by |
|
257 object's call or cell_call method.. |
|
258 """ |
|
259 if initargs is None: |
|
260 initargs = kwargs |
|
261 else: |
|
262 initargs.update(kwargs) |
|
263 try: |
|
264 obj = self.select(__oid, req, rset=rset, **initargs) |
|
265 except NoSelectableObject: |
|
266 if __fallback_oid is None: |
|
267 raise |
|
268 obj = self.select(__fallback_oid, req, rset=rset, **initargs) |
|
269 return obj.render(**kwargs) |
|
270 |
|
271 @deprecated('[3.6] use select_or_none and test for obj.cw_propval("visible")') |
|
272 def select_vobject(self, oid, *args, **kwargs): |
|
273 selected = self.select_or_none(oid, *args, **kwargs) |
|
274 if selected and selected.cw_propval('visible'): |
|
275 return selected |
|
276 return None |
|
277 |
|
278 def poss_visible_objects(self, *args, **kwargs): |
246 def poss_visible_objects(self, *args, **kwargs): |
279 """return an ordered list of possible app objects in a given registry, |
247 """return an ordered list of possible app objects in a given registry, |
280 supposing they support the 'visible' and 'order' properties (as most |
248 supposing they support the 'visible' and 'order' properties (as most |
281 visualizable objects) |
249 visualizable objects) |
282 """ |
250 """ |
283 return sorted([x for x in self.possible_objects(*args, **kwargs) |
251 return sorted([x for x in self.possible_objects(*args, **kwargs) |
284 if x.cw_propval('visible')], |
252 if x.cw_propval('visible')], |
285 key=lambda x: x.cw_propval('order')) |
253 key=lambda x: x.cw_propval('order')) |
286 possible_vobjects = deprecated('[3.6] use poss_visible_objects()')(poss_visible_objects) |
|
287 |
254 |
288 |
255 |
289 VRegistry.REGISTRY_FACTORY[None] = CWRegistry |
256 VRegistry.REGISTRY_FACTORY[None] = CWRegistry |
290 |
257 |
291 |
258 |
814 'from the database)', ex) |
781 'from the database)', ex) |
815 except UnknownProperty, ex: |
782 except UnknownProperty, ex: |
816 self.warning('%s (you should probably delete that property ' |
783 self.warning('%s (you should probably delete that property ' |
817 'from the database)', ex) |
784 'from the database)', ex) |
818 |
785 |
819 # deprecated code #################################################### |
|
820 |
|
821 @deprecated('[3.4] use vreg["etypes"].etype_class(etype)') |
|
822 def etype_class(self, etype): |
|
823 return self["etypes"].etype_class(etype) |
|
824 |
|
825 @deprecated('[3.4] use vreg["views"].main_template(*args, **kwargs)') |
|
826 def main_template(self, req, oid='main-template', **context): |
|
827 return self["views"].main_template(req, oid, **context) |
|
828 |
|
829 @deprecated('[3.4] use vreg[registry].possible_vobjects(*args, **kwargs)') |
|
830 def possible_vobjects(self, registry, *args, **kwargs): |
|
831 return self[registry].possible_vobjects(*args, **kwargs) |
|
832 |
|
833 @deprecated('[3.4] use vreg["actions"].possible_actions(*args, **kwargs)') |
|
834 def possible_actions(self, req, rset=None, **kwargs): |
|
835 return self["actions"].possible_actions(req, rest=rset, **kwargs) |
|
836 |
|
837 @deprecated('[3.4] use vreg["ctxcomponents"].select_object(...)') |
|
838 def select_box(self, oid, *args, **kwargs): |
|
839 return self['boxes'].select_object(oid, *args, **kwargs) |
|
840 |
|
841 @deprecated('[3.4] use vreg["components"].select_object(...)') |
|
842 def select_component(self, cid, *args, **kwargs): |
|
843 return self['components'].select_object(cid, *args, **kwargs) |
|
844 |
|
845 @deprecated('[3.4] use vreg["actions"].select_object(...)') |
|
846 def select_action(self, oid, *args, **kwargs): |
|
847 return self['actions'].select_object(oid, *args, **kwargs) |
|
848 |
|
849 @deprecated('[3.4] use vreg["views"].select(...)') |
|
850 def select_view(self, __vid, req, rset=None, **kwargs): |
|
851 return self['views'].select(__vid, req, rset=rset, **kwargs) |
|
852 |
|
853 |
786 |
854 # XXX unify with yams.constraints.BASE_CONVERTERS? |
787 # XXX unify with yams.constraints.BASE_CONVERTERS? |
855 YAMS_TO_PY = BASE_CONVERTERS.copy() |
788 YAMS_TO_PY = BASE_CONVERTERS.copy() |
856 YAMS_TO_PY.update({ |
789 YAMS_TO_PY.update({ |
857 'Bytes': Binary, |
790 'Bytes': Binary, |