Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes
kss.demo.browser.registry.KSSDemoRegistryView Class Reference
Inheritance diagram for kss.demo.browser.registry.KSSDemoRegistryView:
Inheritance graph
[legend]
Collaboration diagram for kss.demo.browser.registry.KSSDemoRegistryView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getSortedDemos
def getDemoGroups
def getSeleniumTests
def selenium_test_filenames
def getSeleniumTestResource
def getZuiteHomePage
def getZuite

Public Attributes

 zuites

Static Private Member Functions

def _filename_to_title
def _filename_to_href

Private Attributes

 _cooked_selenium_test_filenames

Detailed Description

Definition at line 15 of file registry.py.


Member Function Documentation

Automatic conversion of filename to publication href

Definition at line 77 of file registry.py.

00077 
00078     def _filename_to_href(filename):
00079         """Automatic conversion of filename to publication href"""
00080         return "@@resource?filename=%s" % (filename, )

Here is the caller graph for this function:

Automatic conversion of filename to readable title

Definition at line 60 of file registry.py.

00060 
00061     def _filename_to_title(filename):
00062         """Automatic conversion of filename to readable title"""
00063         if filename.lower().endswith('.html'):
00064             filename = filename[:-5]
00065         elif filename.lower().endswith('.htm'):
00066             filename = filename[:-4]
00067         words = os.path.basename(filename).split('_')
00068         # if the first word is a number: it is ignored in the title
00069         # This can be used to somelimited ordering, since filenames
00070         # are listed in alphabetical order, ie. 00_xxx.html will come first.
00071         if not words[0] or '0' <= words[0][0] <= '9':
00072             words = words[1:]
00073         # Compile the result.
00074         result = ' '.join([word.capitalize() for word in words])
00075         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Get demos groupped by plugin_namespace, category

Definition at line 22 of file registry.py.

00022 
00023     def getDemoGroups(self):
00024         """Get demos groupped by plugin_namespace, category"""
00025         demo_groups = []
00026         prev_plugin_namespace, prev_category = None, None
00027         group = None
00028         for demo in self.getSortedDemos():
00029             plugin_namespace = demo['plugin_namespace']
00030             category =  demo['category']
00031             # Set a flag on first rows in group, 
00032             # since z3 seems not to  handle rpeeat(..).first()
00033             # These will be used for grouping
00034             if prev_plugin_namespace != plugin_namespace:
00035                 is_first_plugin_namespace = True
00036                 prev_plugin_namespace = plugin_namespace
00037             else:
00038                 is_first_plugin_namespace = False
00039             if prev_category != category:
00040                 is_first_category = True
00041                 prev_category = category
00042             else:
00043                 is_first_category = False
00044             # If plugin_namespace or category changed, time to
00045             # start a new group.
00046             if is_first_plugin_namespace or is_first_category:
00047                 # Start a new group.
00048                 group = []
00049                 demo_groups.append(dict(
00050                     plugin_namespace = plugin_namespace,
00051                     category = category,
00052                     demos = group,
00053                     is_first_plugin_namespace = is_first_plugin_namespace,
00054                     is_first_category = is_first_category,
00055                     ))
00056             # In any case append our demo to the group
00057             group.append(demo)
00058         return demo_groups

Here is the call graph for this function:

Return the html resource, whose absolute filename is given,

Definition at line 100 of file registry.py.

00100 
00101     def getSeleniumTestResource(self, filename):
00102         """Return the html resource, whose absolute filename is given,"""
00103         # First of all, let's check if this is one of our file.
00104         # (Refuse otherwise - we don't want access to all files on the server.)
00105         if filename not in self.selenium_test_filenames:
00106             raise Exception, "Nonexistent resource"
00107         # Return the file's content.
00108         self.request.response.setHeader('Content-type', 'text/html;charset=utf-8')
00109         return file(filename).read()

Here is the call graph for this function:

Get selenium tests annotated with title and href.

Definition at line 81 of file registry.py.

00081 
00082     def getSeleniumTests(self):
00083         """Get selenium tests annotated with title and href."""
00084         return [dict(
00085                     href = self._filename_to_href(filename),
00086                     title=self._filename_to_title(filename),
00087                     )
00088                     for filename in self.selenium_test_filenames]

Here is the call graph for this function:

Get demos

Definition at line 17 of file registry.py.

00017 
00018     def getSortedDemos(self):
00019         """Get demos"""
00020         registry = getUtility(IKSSDemoRegistry)
00021         return registry.getSortedDemos()

Here is the caller graph for this function:

Finds a zuite in the same directory or under

Definition at line 116 of file registry.py.

00116 
00117     def getZuite(self):
00118         """Finds a zuite in the same directory or under"""
00119         if not hasattr(self, 'zuites'):
00120             container = self.context.aq_inner.aq_parent
00121             self.zuites = self.context.ZopeFind(container, obj_metatypes=['Zuite'], search_sub=1)
00122         if self.zuites:
00123             return self.zuites[0][1]
00124         else:
00125             return None

Here is the caller graph for this function:

Redirects to the Zuite home page, Zuite object is found from path.

Definition at line 110 of file registry.py.

00110 
00111     def getZuiteHomePage(self):
00112         """Redirects to the Zuite home page, Zuite object is found from path."""
00113         zuite = self.getZuite()
00114         html = "%s/core/TestRunner.html?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url())
00115         return self.request.response.redirect(html)

Here is the call graph for this function:

A cached representation of all filenames.

Definition at line 90 of file registry.py.

00090 
00091     def selenium_test_filenames(self):
00092         """A cached representation of all filenames."""
00093         try:
00094             return self._cooked_selenium_test_filenames
00095         except AttributeError:
00096             registry = getUtility(IKSSDemoRegistry)
00097             self._cooked_selenium_test_filenames =  filenames = \
00098                     registry.selenium_tests
00099             return filenames

Here is the caller graph for this function:


Member Data Documentation

Definition at line 96 of file registry.py.

Definition at line 120 of file registry.py.


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