Beispiel #1
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))
Beispiel #2
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))
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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_')]
Beispiel #6
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_')]
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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))
Beispiel #10
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))