Ejemplo n.º 1
0
    def getPads(self):
        pads = []
        username, password, url = self.getUserData()
        if not (username and password and url):
            return ()

        # try to request etherpad for page with table of pads
        try:
            content = self._getPadsPage()

        except:
            log_exception(_(u"Error during fetching pads from %s" % url),
                context=self.context, logger=logger)
            return ()

        # try to parse html page into pads
        try:
            pads = self._parsePadsPage(content, self.trail_url(url),
                self.data.count)

        except:
            log_exception(_(u"Error during parsing pads page from %s" % url),
                context=self.context, logger=logger)
            return ()

        return tuple(pads)
Ejemplo n.º 2
0
    def get_tabs_info(self, uid):
        """Returns a list with info about the dynamic tabs for author.cpt.

        The list consist in a tuple of (title, url), obtained from the
        registry. The registry contains lines of the form:

            title::path

        The title is localized and the path is converted into an URL, after
        replacing certain strings with the arguments of this method.
        Currently the list of replacements is:

            '{%uid}': Replaced by the uid argument.
        """

        try:
            info = api.portal.get_registry_record(AUTHOR_TABS_KEY)
        except api.exc.InvalidParameterError:
            return []

        base_url = api.portal.get().absolute_url()

        tabs = []
        for line in info:
            title, path, mode = (line.split('::') + ['', '', ''])[:3]
            if not title or not path:
                continue
            path = path.replace('{%uid}', uid)
            url = '{0}/{1}'.format(base_url, path)
            tabs.append((_(title), url, mode))

        return tabs
Ejemplo n.º 3
0
 def update(self):
     self.users = self._getUsers()
     self.header = _(self.data.header)
Ejemplo n.º 4
0
 def __init__(self, header=u'Users', do_not_recurse=False, count=30):
     self.header = _(header)
     self.do_not_recurse = do_not_recurse
     self.count = count
Ejemplo n.º 5
0
 def title(self):
     """Return portlet header"""
     return _(self.header) or _(u"Users Box")