Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Member Functions
kss.demo.registry.KSSDemoRegistry Class Reference

List of all members.

Public Member Functions

def __init__
def registerEarlierDemos
def registerDemosFromPlugin
def unregisterDemosFromPlugin
def registerDemo
def unregisterDemo
def getSortedDemos
def registerSeleniumTestsFromPlugin
def unregisterSeleniumTestsFromPlugin
def registerSeleniumTestFile
def unregisterSeleniumTestFile

Public Attributes

 demos_dict
 demos
 demos_are_sorted
 selenium_tests

Static Private Member Functions

def _getSeleniumTestsFromPlugin

Detailed Description

KSS demo registry.

Definition at line 31 of file registry.py.


Constructor & Destructor Documentation

Definition at line 36 of file registry.py.

00036 
00037     def __init__(self):
00038         # We will set up my handlers to get notified of new plugins
00039         # (works via redispatching by events.py)
00040         site = getSiteManager()
00041         # registry for demos
00042         self.demos_dict = {}
00043         self.demos = []
00044         self.demos_are_sorted = False
00045         site.registerHandler(self.registerDemosFromPlugin)
00046         site.registerHandler(self.unregisterDemosFromPlugin)
00047         site.registerHandler(self.registerEarlierDemos)
00048         # registry for selenium tests
00049         self.selenium_tests = []
00050         site.registerHandler(self.registerSeleniumTestsFromPlugin)
00051         site.registerHandler(self.unregisterSeleniumTestsFromPlugin)
00052         # ... the rest of setup will be done from registerEarlierDemos

Here is the caller graph for this function:


Member Function Documentation

Definition at line 132 of file registry.py.

00132 
00133     def _getSeleniumTestsFromPlugin(plugin):
00134         test_filenames = []
00135         for selenium_test_suite in plugin.selenium_tests:
00136             filenames = getSeleniumTestsFromSuite(plugin,  selenium_test_suite)
00137             test_filenames.extend(filenames)
00138         return test_filenames

Here is the call graph for this function:

Here is the caller graph for this function:

Get the (sorted) list of demos

Definition at line 117 of file registry.py.

00117 
00118     def getSortedDemos(self):
00119         """Get the (sorted) list of demos"""
00120         if not self.demos_are_sorted:
00121             self.demos.sort(key=lambda demo: (
00122                 demo.plugin_namespace,
00123                 demo.category,
00124                 ))
00125             self.demos_are_sorted = True
00126         return list(self.demos)

Register a demo

It has the attributes specified in IKSSDemo:

plugin_namespace - string with the name of the plugin.
           Or: "" when it is the core part.

category         - text that will appear as the title of the
           category. "" if out of category.

demo_page        - (relative) url of the demo page. This should
           traverse on ISimpleContent.

title            - Title of the demo. This also identifies it
           for removal.

Definition at line 83 of file registry.py.

00083 
00084     def registerDemo(self, demo):
00085         """Register a demo
00086 
00087         It has the attributes specified in IKSSDemo:
00088 
00089         plugin_namespace - string with the name of the plugin.
00090                            Or: "" when it is the core part.
00091 
00092         category         - text that will appear as the title of the
00093                            category. "" if out of category.
00094 
00095         demo_page        - (relative) url of the demo page. This should
00096                            traverse on ISimpleContent.
00097 
00098         title            - Title of the demo. This also identifies it
00099                            for removal.
00100         """
00101         key = demo.plugin_namespace, demo.category, demo.page_url
00102         if key in self.demos:
00103             raise Exception, 'The demo for %s has already been registered. Cannot add.' % (key, )
00104         self.demos_dict[key] = demo
00105         self.demos.append(demo)
00106         self.demos_are_sorted = False

Here is the caller graph for this function:

def kss.demo.registry.KSSDemoRegistry.registerDemosFromPlugin (   self,
  plugin,
  registration = None,
  event = None,
  new_event = None 
)
Add a demo collection to the registry.

Definition at line 70 of file registry.py.

00070 
00071     def registerDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None):
00072         """Add a demo collection to the registry.
00073         """
00074         for demo in plugin.demos:
00075             self.registerDemo(demo)

Here is the call graph for this function:

def kss.demo.registry.KSSDemoRegistry.registerEarlierDemos (   self,
  registry,
  registration = None,
  event = None,
  new_event = None 
)
Make sure that the resources registered earlier, are added
 (so this is a listener to the registration of myself
 which is needed because CA is not ready at time of the __init__)

Definition at line 54 of file registry.py.

00054 
00055     def registerEarlierDemos(self, registry, registration=None, event=None, new_event=None):
00056         """Make sure that the resources registered earlier, are added
00057          (so this is a listener to the registration of myself
00058          which is needed because CA is not ready at time of the __init__)
00059         """
00060         if registry != self:
00061             # The utility only register on itself.
00062             return
00063         site = getSiteManager()
00064         for name, plugin in site.getUtilitiesFor(IKSSDemoResource):
00065             for demo in plugin.demos:
00066                 self.registerDemo(demo)
00067             for test_filename in self._getSeleniumTestsFromPlugin(plugin):
00068                 self.registerSeleniumTestFile(test_filename)

Here is the call graph for this function:

Register a selenium test by absolute filename

Definition at line 154 of file registry.py.

00154 
00155     def registerSeleniumTestFile(self, test_filename):
00156         """Register a selenium test by absolute filename
00157         """
00158         if test_filename in self.selenium_tests:
00159             raise Exception, 'The selenium test for %s has already been registered. Cannot add.' % (test_filename, )
00160         self.selenium_tests.append(test_filename)

Here is the caller graph for this function:

def kss.demo.registry.KSSDemoRegistry.registerSeleniumTestsFromPlugin (   self,
  plugin,
  registration = None,
  event = None,
  new_event = None 
)
Add a demo collection to the registry.

Definition at line 140 of file registry.py.

00140 
00141     def registerSeleniumTestsFromPlugin(self, plugin, registration=None, event=None, new_event=None):
00142         """Add a demo collection to the registry.
00143         """
00144         test_filenames = self._getSeleniumTestsFromPlugin(plugin)
00145         for test_filename in test_filenames:
00146             self.registerSeleniumTestFile(test_filename)

Here is the call graph for this function:

Unregister the given demo.

Definition at line 107 of file registry.py.

00107 
00108     def unregisterDemo(self, demo):
00109         """Unregister the given demo."""
00110         key = demo.plugin_namespace, demo.category, demo.demo_page
00111         try:
00112             value = self.demos_dict[key]
00113         except KeyError:
00114             raise Exception, 'The demo for %s is yet unregistered. Cannot remove.' % (key, )
00115         del self.demos_dict[key]
00116         self.demos.remove(value)

Here is the caller graph for this function:

def kss.demo.registry.KSSDemoRegistry.unregisterDemosFromPlugin (   self,
  plugin,
  registration = None,
  event = None,
  new_event = None 
)
Remove a demo collection from the registry.

Definition at line 77 of file registry.py.

00077 
00078     def unregisterDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None):
00079         """Remove a demo collection from the registry.
00080         """
00081         for demo in plugin.demos:
00082             self.unregisterDemo(demo)

Here is the call graph for this function:

Unregister the given selenium test.

Definition at line 161 of file registry.py.

00161 
00162     def unregisterSeleniumTestFile(self, test_filename):
00163         """Unregister the given selenium test."""
00164         try:
00165             del self.selenium_tests[test_filename]
00166         except KeyError:
00167             raise Exception, 'The selenium test for %s is yet unregistered. Cannot remove.' % (test_filename, )
def kss.demo.registry.KSSDemoRegistry.unregisterSeleniumTestsFromPlugin (   self,
  plugin,
  registration = None,
  event = None,
  new_event = None 
)
Remove a demo collection from the registry.

Definition at line 148 of file registry.py.

00148 
00149     def unregisterSeleniumTestsFromPlugin(self, plugin, registration=None, event=None, new_event=None):
00150         """Remove a demo collection from the registry.
00151         """
00152         for test_filename in self._getSeleniumTestsFromPlugin(plugin):
00153             self.registerSeleniumTestFile(test_filename)

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file registry.py.

Definition at line 43 of file registry.py.

Definition at line 41 of file registry.py.

Definition at line 48 of file registry.py.


The documentation for this class was generated from the following file: