Author: jvloothuis
Date: Sun Nov 11 13:34:12 2007
New Revision: 48557
Modified:
kukit/kss.zope/trunk/kss/zope/registry.py
kukit/kss.zope/trunk/kss/zope/registry.txt
Log:
Added BBB methods for registering specific stuff (will be used for ZCML BBB
with old plugins)
Modified: kukit/kss.zope/trunk/kss/zope/registry.py
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/registry.py (original)
+++ kukit/kss.zope/trunk/kss/zope/registry.py Sun Nov 11 13:34:12 2007
@@ -8,27 +8,47 @@
def __init__(self):
self._commandsets = {}
-
for plugin_id, config in available_plugins():
self._commandsets.update(config.commandsets)
- def plugins(self):
- return available_plugins()
-
- def javascripts(self):
+ self._javascripts = []
for id, config in self.plugins():
for javascript in config.javascripts:
- yield javascript
+ self._javascripts.append(javascript)
- def extra_javascripts(self):
+ self._extra_javascripts = []
for id, config in self.plugins():
for extra_javascript in config.extra_javascripts:
- yield extra_javascript
+ self._extra_javascripts.append(extra_javascript)
+ def plugins(self):
+ return available_plugins()
+
+ def javascripts(self):
+ return self._javascripts
+
+ def extra_javascripts(self):
+ return self._extra_javascripts
def lookup_commandset(self, id):
return self._commandsets[id]
+ #=============================================
+ # Stuff needed for compatibility features
+ #=============================================
+ def bbb_register_commandset(self, id, factory):
+ # make sure we only register when we do not have a better
+ # (new-style plugin) commandset
+ if not id in self._commandsets:
+ self._commandsets[id] = factory
+
+ def bbb_register_javascript(self, filename):
+ if filename not in self._javascripts:
+ self._javascripts.append(filename)
+
+ def bbb_register_extra_javascript(self, filename):
+ if filename not in self._extra_javascripts:
+ self._extra_javascripts.append(filename)
+
- def register_commandset(self, id, factory):
- self._commandsets[id] = factory
+
Modified: kukit/kss.zope/trunk/kss/zope/registry.txt
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/registry.txt (original)
+++ kukit/kss.zope/trunk/kss/zope/registry.txt Sun Nov 11 13:34:12 2007
@@ -53,6 +53,13 @@
As you can see it returns a factory (in this case the class) for the
commandset.
+
+BBB
+===
+
+The code below is only used for backwards compatibility. It will be
+removed in a future release.
+
Next to automatically discovering commandsets (using the plugin
system) there is support for registering a specific set. The
registration is a simple call to the registry with a commandset
@@ -61,6 +68,25 @@
>>> from kss.base.commands import KSSCommandSet
>>> class CheeseCommandSet(KSSCommandSet):
... pass
- >>> registry.register_commandset('cheese', CheeseCommandSet)
+ >>> registry.bbb_register_commandset('cheese', CheeseCommandSet)
>>> registry.lookup_commandset('cheese')
- <class 'CheeseCommandSet'>
\ No newline at end of file
+ <class 'CheeseCommandSet'>
+
+If we register an already available one it will silently ignore the
+request. It will also keep the existing one.
+
+ >>> registry.bbb_register_commandset('core', CheeseCommandSet)
+ >>> registry.lookup_commandset('core')
+ <class 'kss.base.corecommands.KSSCoreCommands'>
+
+We can also add Javascript files.
+
+ >>> registry.bbb_register_javascript('/some/path.js')
+ >>> list(registry.javascripts())
+ [..., '/some/path.js']
+
+
+ >>> registry.bbb_register_extra_javascript('/some_other/path.js')
+ >>> list(registry.extra_javascripts())
+ [..., '/some_other/path.js']
+
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins