# HG changeset patch # User Adrien Di Mascio # Date 1249405134 -7200 # Node ID 38a4e83c8160632d58b83f9354b3706fb318220c # Parent 44f041222d0fa99f9f676ba3f7b2b1181c4d035f# Parent 6220500bada7387535a0c9970633fb9bfbb5af3d merge diff -r 6220500bada7 -r 38a4e83c8160 __init__.py --- a/__init__.py Tue Aug 04 18:47:11 2009 +0200 +++ b/__init__.py Tue Aug 04 18:58:54 2009 +0200 @@ -348,3 +348,18 @@ callback(context, *args, **kwargs) CW_EVENT_MANAGER = CubicWebEventManager() + +def onevent(event): + """decorator to ease event / callback binding + + >>> from cubicweb import onevent + >>> @onevent('before-source-reload') + ... def mycallback(): + ... print 'hello' + ... + >>> + """ + def _decorator(func): + CW_EVENT_MANAGER.bind(event, func) + return func + return _decorator diff -r 6220500bada7 -r 38a4e83c8160 rtags.py --- a/rtags.py Tue Aug 04 18:47:11 2009 +0200 +++ b/rtags.py Tue Aug 04 18:58:54 2009 +0200 @@ -41,6 +41,9 @@ return self.get(*key) __contains__ = __getitem__ + def clear(self): + self._tagdefs.clear() + def _get_keys(self, stype, rtype, otype, tagged): keys = [(rtype, tagged, '*', '*'), (rtype, tagged, '*', otype), diff -r 6220500bada7 -r 38a4e83c8160 vregistry.py --- a/vregistry.py Tue Aug 04 18:47:11 2009 +0200 +++ b/vregistry.py Tue Aug 04 18:58:54 2009 +0200 @@ -35,13 +35,6 @@ RegistryOutOfDate) from cubicweb.appobject import AppObject -# XXX depending on cubicweb.web is ugly, we should deal with uicfg -# reset with a good old event / callback system -try: - from cubicweb.web import uicfg -except ImportError: # cubicweb.web not installed - uicfg = None - def _toload_info(path, extrapath, _toload=None): """return a dictionary of : and an ordered list of (file, module name) to load @@ -216,12 +209,6 @@ def reset(self, force_reload=None): self.clear() self._lastmodifs = {} - # don't reload uicfg when appobjects modules won't be reloaded as well - if uicfg is not None: - if force_reload is None: - force_reload = self.config.mode == 'dev' - if force_reload: - reload(uicfg) def __getitem__(self, name): """return the registry (dictionary of class objects) associated to diff -r 6220500bada7 -r 38a4e83c8160 web/uicfg.py --- a/web/uicfg.py Tue Aug 04 18:47:11 2009 +0200 +++ b/web/uicfg.py Tue Aug 04 18:58:54 2009 +0200 @@ -67,7 +67,7 @@ """ __docformat__ = "restructuredtext en" -from cubicweb import neg_role +from cubicweb import neg_role, onevent from cubicweb.rtags import (RelationTags, RelationTagsBool, RelationTagsSet, RelationTagsDict) from cubicweb.web import formwidgets @@ -144,7 +144,6 @@ primaryview_display_ctrl = DisplayCtrlRelationTags('primaryview_display_ctrl', init_primaryview_display_ctrl) - # index view configuration #################################################### # entity type section in the index/manage page. May be one of # * 'application' @@ -205,7 +204,6 @@ # permissions checking is by-passed and supposed to be ok autoform_permissions_overrides = RelationTagsSet('autoform_permissions_overrides') - # boxes.EditBox configuration ################################################# # 'link' / 'create' relation tags, used to control the "add entity" submenu @@ -219,3 +217,14 @@ actionbox_appearsin_addmenu = RelationTagsBool('actionbox_appearsin_addmenu', init_actionbox_appearsin_addmenu) +@onevent('before-source-reload') +def clear_rtag_objects(): + print 'YAHOO ' * 80 + primaryview_section.clear() + primaryview_display_ctrl.clear() + autoform_section.clear() + autoform_field.clear() + autoform_field_kwargs.clear() + autoform_is_inlined.clear() + autoform_permissions_overrides.clear() + actionbox_appearsin_addmenu.clear()