Example #1
0
 def getPackageIds(self):
     """
     Returns sorted list of all enabled package ids.
     """
     all = PackageManager.getPackageIds()
     enabled = [id for id in all if self.env.isComponentEnabled \
                (PackageManager.getClasses(IPackage, id)[0])]
     return sorted(enabled)
Example #2
0
 def getPackageIds(self):
     """
     Returns sorted list of all enabled package ids.
     """
     all = PackageManager.getPackageIds()
     enabled = [id for id in all if self.env.isComponentEnabled \
                (PackageManager.getClasses(IPackage, id)[0])]
     return sorted(enabled)
Example #3
0
 def _registerStaticContent(self):
     """
     Register all static content.
     """
     # register default static content
     for id in ['images', 'css', 'js', 'yui2']:
         path = os.path.join(self.statics_dir, id)
         self.putChild(id, FileSystemResource(path, public=True))
     # favicon
     filename = os.path.join(self.statics_dir, 'favicon.ico')
     res = FileSystemResource(filename,
                              "image/x-icon",
                              hidden=True,
                              public=True)
     self.putChild('favicon.ico', res)
     # start page
     filename = os.path.join(self.statics_dir, 'welcome.html')
     res = FileSystemResource(filename,
                              "text/html; charset=UTF-8",
                              hidden=True,
                              public=True)
     self.putChild('welcome', res)
     # register additional static content defined by plug-ins
     static_contents = PackageManager.getComponents(IAdminStaticContent,
                                                    None, self.env)
     for res in static_contents:
         # sanity checks
         if not hasattr(res, 'getStaticContent'):
             msg = 'Method getStaticContent() missing in %s' % res
             self.env.log.warn(msg)
             continue
         items = res.getStaticContent()
         for path, file in items.iteritems():
             self.putChild(path, FileSystemResource(file, public=True))
Example #4
0
 def _registerStaticContent(self):
     """
     Register all static content.
     """
     # register default static content
     for id in ['images', 'css', 'js', 'yui2']:
         path = os.path.join(self.statics_dir, id)
         self.putChild(id, FileSystemResource(path, public=True))
     # favicon
     filename = os.path.join(self.statics_dir, 'favicon.ico')
     res = FileSystemResource(filename, "image/x-icon", hidden=True,
                              public=True)
     self.putChild('favicon.ico', res)
     # start page
     filename = os.path.join(self.statics_dir, 'welcome.html')
     res = FileSystemResource(filename, "text/html; charset=UTF-8",
                              hidden=True, public=True)
     self.putChild('welcome', res)
     # register additional static content defined by plug-ins
     static_contents = PackageManager.getComponents(IAdminStaticContent,
                                                    None, self.env)
     for res in static_contents:
         # sanity checks
         if not hasattr(res, 'getStaticContent'):
             msg = 'Method getStaticContent() missing in %s' % res
             self.env.log.warn(msg)
             continue
         items = res.getStaticContent()
         for path, file in items.iteritems():
             self.putChild(path, FileSystemResource(file, public=True))
Example #5
0
 def getComponents(self, interface, package_id=None):
     """
     Returns components implementing a certain interface with a given 
     package_id.
     """
     components = PackageManager.getComponents(interface, package_id,
                                               self.env)
     return components
Example #6
0
 def getComponents(self, interface, package_id=None):
     """
     Returns components implementing a certain interface with a given 
     package_id.
     """
     components = PackageManager.getComponents(interface, package_id,
                                               self.env)
     return components
Example #7
0
 def update(self):
     """
     Refresh all ProcessorIndexes.
     """
     self.env.log.debug("Updating ProcessorIndexes ...")
     all = PackageManager.getClasses(IProcessorIndex)
     for cls in all:
         if self.env.isComponentEnabled(cls):
             self._enableProcessorIndex(cls)
         else:
             self._disableProcessorIndex(cls)
     self.env.log.info("ProcessorIndexes have been updated.")
Example #8
0
 def update(self):
     """
     Refresh all ProcessorIndexes.
     """
     self.env.log.debug("Updating ProcessorIndexes ...")
     all = PackageManager.getClasses(IProcessorIndex)
     for cls in all:
         if self.env.isComponentEnabled(cls):
             self._enableProcessorIndex(cls)
         else:
             self._disableProcessorIndex(cls)
     self.env.log.info("ProcessorIndexes have been updated.")
Example #9
0
 def __init__(self, avatar):
     recvline.HistoricRecvLine.__init__(self)
     self.user = avatar
     self.env = avatar.env
     self.status = {}
     plugins = PackageManager.getComponents(ISSHCommand, None, self.env)
     self.plugin_cmds = dict([
         (p.command_id.upper(), p) for p in plugins
         if hasattr(p, 'executeCommand') and hasattr(p, 'command_id')
     ])
     self.buildin_cmds = [f[4:].upper() for f in dir(self) \
                          if f.startswith('cmd_')]
Example #10
0
 def __init__(self, avatar):
     recvline.HistoricRecvLine.__init__(self)
     self.user = avatar
     self.env = avatar.env
     self.status = {}
     plugins = PackageManager.getComponents(ISSHCommand, None, self.env)
     self.plugin_cmds = dict([(p.command_id.upper(), p)
                              for p in plugins
                              if hasattr(p, 'executeCommand')
                              and hasattr(p, 'command_id')])
     self.buildin_cmds = [f[4:].upper() for f in dir(self) \
                          if f.startswith('cmd_')]
Example #11
0
 def update(self):
     """
     Refresh all SQL views.
     """
     self.env.log.debug("Updating SQLViews ...")
     self._view_objs = dict()
     all = PackageManager.getClasses(ISQLView)
     for cls in all:
         if self.env.isComponentEnabled(cls):
             self._enableView(cls)
         elif hasattr(cls, 'view_id') and cls.view_id in self._view_objs:
             self._disableView(cls)
     self.env.log.info("SQLViews have been updated.")
Example #12
0
 def update(self):
     """
     Refresh all SQL views.
     """
     self.env.log.debug("Updating SQLViews ...")
     self._view_objs = dict()
     all = PackageManager.getClasses(ISQLView)
     for cls in all:
         if self.env.isComponentEnabled(cls):
             self._enableView(cls)
         elif hasattr(cls, 'view_id') and cls.view_id in self._view_objs:
             self._disableView(cls)
     self.env.log.info("SQLViews have been updated.")
Example #13
0
 def update(self):
     """
     Refresh the mapper registry.
     """
     self._urls = dict()
     all = PackageManager.getClasses(IMapper)
     for cls in all:
         if not self.env.isComponentEnabled(cls):
             continue
         # sanity checks
         if not hasattr(cls, 'mapping_url'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute mapping_url is missing."
             self.env.log.warn(msg % (cls, IMapper))
             continue
         self._urls[cls.mapping_url] = cls
Example #14
0
 def update(self):
     """
     Refresh the mapper registry.
     """
     self._urls = dict()
     all = PackageManager.getClasses(IMapper)
     for cls in all:
         if not self.env.isComponentEnabled(cls):
             continue
         # sanity checks
         if not hasattr(cls, 'mapping_url'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute mapping_url is missing."
             self.env.log.warn(msg % (cls, IMapper))
             continue
         self._urls[cls.mapping_url] = cls
Example #15
0
 def _registerAdminThemes(self):
     """
     Register all administrative themes.
     """
     self.themes = {}
     themes = PackageManager.getComponents(IAdminTheme, None, self.env)
     for theme in themes:
         # sanity checks
         if not hasattr(theme, 'theme_id'):
             msg = 'Attribute theme_id missing in %s' % theme
             self.env.log.warn(msg)
             continue
         if not hasattr(theme, 'theme_css_resource'):
             msg = 'Attribute theme_css_resource missing in %s' % theme
             self.env.log.warn(msg)
             continue
         self.themes[theme.theme_id] = theme
Example #16
0
 def _registerAdminThemes(self):
     """
     Register all administrative themes.
     """
     self.themes = {}
     themes = PackageManager.getComponents(IAdminTheme, None, self.env)
     for theme in themes:
         # sanity checks
         if not hasattr(theme, 'theme_id'):
             msg = 'Attribute theme_id missing in %s' % theme
             self.env.log.warn(msg)
             continue
         if not hasattr(theme, 'theme_css_resource'):
             msg = 'Attribute theme_css_resource missing in %s' % theme
             self.env.log.warn(msg)
             continue
         self.themes[theme.theme_id] = theme
Example #17
0
 def getAllPackagesAndResourceTypes(self):
     """
     Returns dictionary of enabled resource type and package IDs.
     
     List of resource types of each package is sorted.
     
     @return: {'package_id': ['resourcetype_id_1', 'resourcetype_id_2']}
     @rtype: dictionary
     """
     ids = self.getPackageIds()
     resourcetypes = dict()
     for id in ids:
         all = PackageManager.getClasses(IResourceType, id)
         resourcetypes[id] = [cls.resourcetype_id for cls in all \
                             if self.env.isComponentEnabled(cls)]
     # sort
     for id in resourcetypes.keys():
         resourcetypes[id] = sorted(resourcetypes[id])
     return resourcetypes
Example #18
0
 def getAllPackagesAndResourceTypes(self):
     """
     Returns dictionary of enabled resource type and package IDs.
     
     List of resource types of each package is sorted.
     
     @return: {'package_id': ['resourcetype_id_1', 'resourcetype_id_2']}
     @rtype: dictionary
     """
     ids = self.getPackageIds()
     resourcetypes = dict()
     for id in ids:
         all = PackageManager.getClasses(IResourceType, id)
         resourcetypes[id] = [cls.resourcetype_id for cls in all \
                             if self.env.isComponentEnabled(cls)]
     # sort
     for id in resourcetypes.keys():
         resourcetypes[id] = sorted(resourcetypes[id])
     return resourcetypes
Example #19
0
 def update(self):
     """
     Refresh the ResourceFormater registry.
     """
     self.env.log.debug("Updating ResourceFormaters ...")
     self._dict = dict()
     all = PackageManager.getClasses(IResourceFormater)
     for cls in all:
         if not self.env.isComponentEnabled(cls):
             continue
         # sanity checks
         if not hasattr(cls, 'package_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute package_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         if not hasattr(cls, 'resourcetype_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute resourcetype_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         if not hasattr(cls, 'format_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute format_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         # format may be a list of strings
         formats = cls.format_id
         if isinstance(formats, basestring):
             formats = list(formats)
         if not isinstance(cls.format_id, list):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute format_id must be a list or string instance."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         for format in formats:
             ids = (cls.package_id, cls.resourcetype_id, format)
             self._dict[ids] = cls
     self.env.log.info("ResourceFormater have been updated.")
Example #20
0
 def update(self):
     """
     Refresh the ResourceFormater registry.
     """
     self.env.log.debug("Updating ResourceFormaters ...")
     self._dict = dict()
     all = PackageManager.getClasses(IResourceFormater)
     for cls in all:
         if not self.env.isComponentEnabled(cls):
             continue
         # sanity checks
         if not hasattr(cls, 'package_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute package_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         if not hasattr(cls, 'resourcetype_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute resourcetype_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         if not hasattr(cls, 'format_id'):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute format_id is missing."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         # format may be a list of strings
         formats = cls.format_id
         if isinstance(formats, basestring):
             formats = list(formats)
         if not isinstance(cls.format_id, list):
             msg = "Class %s has a wrong implementation of %s. " + \
                   "Attribute format_id must be a list or string instance."
             self.env.log.warn(msg % (cls, IResourceFormater))
             continue
         for format in formats:
             ids = (cls.package_id, cls.resourcetype_id, format)
             self._dict[ids] = cls
     self.env.log.info("ResourceFormater have been updated.")
Example #21
0
 def _registerAdminPanels(self):
     """
     Register all administrative panels.
     """
     temp = {}
     self.mainmenu = {}
     self.submenu = {}
     panels = PackageManager.getComponents(IAdminPanel, None, self.env)
     for panel in panels:
         # sanity checks
         if not hasattr(panel, 'panel_ids'):
             msg = 'Attribute panel_ids missing in %s' % panel
             self.env.log.warn(msg)
             continue
         if len(panel.panel_ids) != 4:
             msg = 'Attribute panel_ids got wrong format in %s' % panel
             self.env.log.warn(msg)
             continue
         if not hasattr(panel, 'template'):
             msg = 'Attribute template missing in %s' % panel
             self.env.log.warn(msg)
             continue
         if not hasattr(panel, 'render'):
             msg = 'Method render() missing in %s.' % panel
             self.env.log.info(msg)
         # set default values
         if not hasattr(panel, 'public'):
             panel.public = False
         # create child
         cid, cname, pid, pname = panel.panel_ids
         temp.setdefault(cid, [])
         temp[cid].append(panel)
         # main menu items
         self.mainmenu[cid] = cname
         # sub menu items
         self.submenu.setdefault(cid, {})
         self.submenu[cid][pid] = pname
     for id, panels in temp.iteritems():
         self.putChild(id, AdminFolder(self, panels))
Example #22
0
 def _registerAdminPanels(self):
     """
     Register all administrative panels.
     """
     temp = {}
     self.mainmenu = {}
     self.submenu = {}
     panels = PackageManager.getComponents(IAdminPanel, None, self.env)
     for panel in panels:
         # sanity checks
         if not hasattr(panel, 'panel_ids'):
             msg = 'Attribute panel_ids missing in %s' % panel
             self.env.log.warn(msg)
             continue
         if len(panel.panel_ids) != 4:
             msg = 'Attribute panel_ids got wrong format in %s' % panel
             self.env.log.warn(msg)
             continue
         if not hasattr(panel, 'template'):
             msg = 'Attribute template missing in %s' % panel
             self.env.log.warn(msg)
             continue
         if not hasattr(panel, 'render'):
             msg = 'Method render() missing in %s.' % panel
             self.env.log.info(msg)
         # set default values
         if not hasattr(panel, 'public'):
             panel.public = False
         # create child
         cid, cname, pid, pname = panel.panel_ids
         temp.setdefault(cid, [])
         temp[cid].append(panel)
         # main menu items
         self.mainmenu[cid] = cname
         # sub menu items
         self.submenu.setdefault(cid, {})
         self.submenu[cid][pid] = pname
     for id, panels in temp.iteritems():
         self.putChild(id, AdminFolder(self, panels))
Example #23
0
 def getResourceTypes(self, package_id):
     """
     Returns a list of all enabled resource types for a given package id.
     """
     all = PackageManager.getClasses(IResourceType, package_id)
     return [cls for cls in all if self.env.isComponentEnabled(cls)]
Example #24
0
 def getResourceTypes(self, package_id):
     """
     Returns a list of all enabled resource types for a given package id.
     """
     all = PackageManager.getClasses(IResourceType, package_id)
     return [cls for cls in all if self.env.isComponentEnabled(cls)]