--- a/common/registerers.py Wed Apr 22 16:56:19 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-"""This file contains some basic registerers required by application objects
-registry to handle registration at startup time.
-
-A registerer is responsible to tell if an object should be registered according
-to the application's schema or to already registered object
-
-:organization: Logilab
-:copyright: 2006-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-"""
-__docformat__ = "restructuredtext en"
-
-from cubicweb.vregistry import registerer, yes_registerer
-from cubicweb.cwvreg import use_interfaces
-
-class priority_registerer(registerer):
- """systematically kick previous registered class and register the
- wrapped class (based on the fact that directory containing vobjects
- are loaded from the most generic to the most specific).
-
- This is usually for templates or startup views where we want to
- keep only the latest in the load path
- """
- def do_it_yourself(self, registered):
- if registered:
- if len(registered) > 1:
- self.warning('priority_registerer found more than one registered objects '
- '(registerer monkey patch ?)')
- for regobj in registered[:]:
- self.kick(registered, regobj)
- return self.vobject
-
- def remove_equivalents(self, registered):
- for _obj in registered[:]:
- if self.equivalent(_obj):
- self.kick(registered, _obj)
- break
-
- def remove_all_equivalents(self, registered):
- for _obj in registered[:]:
- if _obj is self.vobject:
- continue
- if self.equivalent(_obj):
- self.kick(registered, _obj)
-
- def equivalent(self, other):
- raise NotImplementedError(self, self.vobject)
-
-
-class accepts_registerer(priority_registerer):
- """register according to the .accepts attribute of the wrapped
- class, which should be a tuple refering some entity's types
-
- * if no type is defined the application'schema, skip the wrapped
- class
- * if the class defines a requires attribute, each entity type defined
- in the requires list must be in the schema
- * if an object previously registered has equivalent .accepts
- attribute, kick it out
- * register
- """
- def do_it_yourself(self, registered):
- # if object is accepting interface, we have register it now and
- # remove it later if no object is implementing accepted interfaces
- if use_interfaces(self.vobject):
- return self.vobject
- self.remove_equivalents(registered)
- return self.vobject
-
- def equivalent(self, other):
- if use_interfaces(self.vobject) != use_interfaces(other):
- return False
- if getattr(self.vobject, 'require_groups', ()) != getattr(other, 'require_groups', ()):
- return False
- try:
- newaccepts = list(other.accepts)
- for etype in self.vobject.accepts:
- try:
- newaccepts.remove(etype)
- except ValueError:
- continue
- if newaccepts:
- other.accepts = tuple(newaccepts)
- return False
- return True
- except AttributeError:
- return False
-
-
-__all__ = [cls.__name__ for cls in globals().values()
- if isinstance(cls, type) and issubclass(cls, registerer)
- and not cls is registerer]
--- a/goa/goactl.py Wed Apr 22 16:56:19 2009 +0200
+++ b/goa/goactl.py Wed Apr 22 18:42:58 2009 +0200
@@ -65,7 +65,6 @@
'common/migration.py',
'common/mixins.py',
'common/mttransforms.py',
- 'common/registerers.py',
'common/uilib.py',
'ext/html4zope.py',
--- a/view.py Wed Apr 22 16:56:19 2009 +0200
+++ b/view.py Wed Apr 22 18:42:58 2009 +0200
@@ -17,8 +17,6 @@
from cubicweb.selectors import require_group_compat, accepts_compat
from cubicweb.appobject import AppRsetObject
from cubicweb.utils import UStringIO, HTMLStream
-from cubicweb.vregistry import yes_registerer
-from cubicweb.common.registerers import accepts_registerer, priority_registerer, yes_registerer
_ = unicode
@@ -93,7 +91,6 @@
time to a write function to use.
"""
__registry__ = 'views'
- __registerer__ = priority_registerer
registered = require_group_compat(AppRsetObject.registered)
templatable = True
@@ -320,7 +317,6 @@
class EntityView(View):
"""base class for views applying on an entity (i.e. uniform result set)"""
- __registerer__ = accepts_registerer
__select__ = non_final_entity()
registered = accepts_compat(View.registered)
@@ -331,7 +327,6 @@
"""base class for views which doesn't need a particular result set to be
displayed (so they can always be displayed !)
"""
- __registerer__ = priority_registerer
__select__ = none_rset()
registered = require_group_compat(View.registered)
@@ -483,7 +478,6 @@
class Component(ReloadableMixIn, View):
"""base class for components"""
__registry__ = 'components'
- __registerer__ = yes_registerer
__select__ = yes()
property_defs = {
_('visible'): dict(type='Boolean', default=True,
--- a/vregistry.py Wed Apr 22 16:56:19 2009 +0200
+++ b/vregistry.py Wed Apr 22 18:42:58 2009 +0200
@@ -7,11 +7,6 @@
* to interact with the vregistry, object should inherit from the
VObject abstract class
-* the registration procedure is delegated to a registerer. Each
- registerable vobject must defines its registerer class using the
- __registerer__ attribute. A registerer is instantianted at
- registration time after what the instance is lost
-
* the selection procedure has been generalized by delegating to a
selector, which is responsible to score the vobject according to the
current state (req, rset, row, col). At the end of the selection, if
@@ -53,42 +48,6 @@
return _toload
-class registerer(object):
- """do whatever is needed at registration time for the wrapped
- class, according to current application schema and already
- registered objects of the same kind (i.e. same registry name and
- same id).
-
- The wrapped class may be skipped, some previously selected object
- may be kicked out... After whatever works needed, if the object or
- a transformed object is returned, it will be added to previously
- registered objects.
- """
-
- def __init__(self, registry, vobject):
- self.registry = registry
- self.vobject = vobject
- self.config = registry.config
- self.schema = registry.schema
- self.kicked = set()
-
- def do_it_yourself(self, registered):
- raise NotImplementedError(str(self.vobject))
-
- def kick(self, registered, kicked):
- self.debug('kicking vobject %s', kicked)
- registered.remove(kicked)
- self.kicked.add(kicked.classid())
-
- def skip(self):
- self.debug('no schema compat, skipping %s', self.vobject)
-
-class yes_registerer(registerer):
- """register without any other action"""
- def do_it_yourself(self, registered):
- return self.vobject
-
-
class VObject(object):
"""visual object, use to be handled somehow by the visual components
registry.
@@ -110,7 +69,6 @@
# necessary attributes to interact with the registry
id = None
__registry__ = None
- __registerer__ = yes_registerer
__select__ = None
@classmethod
@@ -469,8 +427,6 @@
with a name starting starting by an underscore are not registered.
Also a vobject class needs to have __registry__ and id attributes set
to a non empty string to be registered.
-
- Registration is actually handled by vobject's registerer.
"""
if (cls.__dict__.get('__abstract__') or cls.__name__[0] == '_'
or not cls.__registry__ or not cls.id):
@@ -478,12 +434,7 @@
regname = cls.__registry__
if '%s.%s' % (regname, cls.id) in self.config['disable-appobjects']:
return
- registry = self._registries.setdefault(regname, {})
- vobjects = registry.setdefault(cls.id, [])
- registerer = cls.__registerer__(self, cls)
- cls = registerer.do_it_yourself(vobjects)
- if cls:
- self.register(cls)
+ self.register(cls)
def unregister_module_vobjects(self, modname):
"""removes registered objects coming from a given module
@@ -550,7 +501,6 @@
# init logging
set_log_methods(VObject, getLogger('cubicweb'))
set_log_methods(VRegistry, getLogger('cubicweb.registry'))
-set_log_methods(registerer, getLogger('cubicweb.registration'))
# selector base classes and operations ########################################
--- a/web/action.py Wed Apr 22 16:56:19 2009 +0200
+++ b/web/action.py Wed Apr 22 18:42:58 2009 +0200
@@ -11,7 +11,6 @@
one_line_rset, partial_may_add_relation, yes,
accepts_compat, condition_compat, deprecate)
from cubicweb.appobject import AppRsetObject
-from cubicweb.common.registerers import accepts_registerer
_ = unicode
@@ -21,7 +20,6 @@
request search state.
"""
__registry__ = 'actions'
- __registerer__ = accepts_registerer
__select__ = yes()
property_defs = {
--- a/web/component.py Wed Apr 22 16:56:19 2009 +0200
+++ b/web/component.py Wed Apr 22 18:42:58 2009 +0200
@@ -16,7 +16,6 @@
paginated_rset, one_line_rset, primary_view, match_context_prop,
partial_has_related_entities, condition_compat, accepts_compat,
has_relation_compat)
-from cubicweb.common.registerers import accepts_registerer
_ = unicode
@@ -32,7 +31,6 @@
"""
__registry__ = 'contentnavigation'
- __registerer__ = accepts_registerer
__select__ = one_line_rset() & primary_view() & match_context_prop()
registered = accepts_compat(has_relation_compat(condition_compat(View.registered)))
--- a/web/controller.py Wed Apr 22 16:56:19 2009 +0200
+++ b/web/controller.py Wed Apr 22 18:42:58 2009 +0200
@@ -11,7 +11,6 @@
from cubicweb import typed_eid
from cubicweb.utils import strptime
-from cubicweb.common.registerers import priority_registerer
from cubicweb.selectors import yes, require_group_compat
from cubicweb.appobject import AppObject
from cubicweb.web import LOGGER, Redirect, RequestError
@@ -68,7 +67,6 @@
and another linked by forms to edit objects ("edit").
"""
__registry__ = 'controllers'
- __registerer__ = priority_registerer
__select__ = yes()
registered = require_group_compat(AppObject.registered)
--- a/web/facet.py Wed Apr 22 16:56:19 2009 +0200
+++ b/web/facet.py Wed Apr 22 18:42:58 2009 +0200
@@ -21,7 +21,6 @@
from cubicweb import Unauthorized, typed_eid
from cubicweb.selectors import match_context_prop, partial_relation_possible
from cubicweb.appobject import AppRsetObject
-from cubicweb.common.registerers import priority_registerer
from cubicweb.web.htmlwidgets import HTMLWidget
## rqlst manipulation functions used by facets ################################
@@ -239,7 +238,6 @@
## base facet classes #########################################################
class AbstractFacet(AppRsetObject):
- __registerer__ = priority_registerer
__abstract__ = True
__registry__ = 'facets'
property_defs = {
--- a/web/views/urlrewrite.py Wed Apr 22 16:56:19 2009 +0200
+++ b/web/views/urlrewrite.py Wed Apr 22 18:42:58 2009 +0200
@@ -7,7 +7,6 @@
import re
from cubicweb.appobject import AppObject
-from cubicweb.common.registerers import accepts_registerer
def rgx(pattern, flags=0):
@@ -53,7 +52,6 @@
"""
__metaclass__ = metarewriter
__registry__ = 'urlrewriting'
- __registerer__ = accepts_registerer
__abstract__ = True
id = 'urlrewriting'