示例#1
0
 def _make_identity(self):
     page = wikiutil.getHomePage(self.request)
     if page:
         server_url = self.request.getQualifiedURL(
                          page.url(self.request, querystr={'action': 'serveopenid'}))
         identity = self.request.getQualifiedURL(page.url(self.request))
         return identity, server_url
     return None, None
示例#2
0
    def getEditorData(self, request):
        """ Return a tuple of type id and string or Page object
            representing the user that did the edit.

            The type id is one of 'ip' (DNS or numeric IP), 'user' (user name)
            or 'homepage' (Page instance of user's homepage).
        """
        result = ('ip', (request.cfg.show_hosts and self.hostname) or '')
        if self.userid:
            if not self._usercache.has_key(self.userid):
                self._usercache[self.userid] = user.User(request, self.userid)
            userdata = self._usercache[self.userid]
            if userdata.name:
                pg = wikiutil.getHomePage(request, username=userdata.name)
                if pg:
                    result = ('homepage', pg)
                else:
                    result = ('user', userdata.name)

        return result
示例#3
0
文件: editlog.py 项目: happytk/moin
    def getEditorData(self, request):
        """ Return a tuple of type id and string or Page object
            representing the user that did the edit.

            DEPRECATED - try to use getInterwikiEditorData
            NOT USED ANY MORE BY MOIN CODE!

            The type id is one of 'ip' (DNS or numeric IP), 'user' (user name)
            or 'homepage' (Page instance of user's homepage).
        """
        result = "ip", request.cfg.show_hosts and self.hostname or ""
        if self.userid:
            if self.userid not in self._usercache:
                self._usercache[self.userid] = user.User(request, self.userid, auth_method="editlog:53")
            userdata = self._usercache[self.userid]
            if userdata.name:
                pg = wikiutil.getHomePage(request, username=userdata.name)
                if pg:
                    result = ("homepage", pg)
                else:
                    result = ("user", userdata.name)

        return result
示例#4
0
    def _make_backup(self, newtext, **kw):
        """ Make editor backup on user homepage

        Replace text of the user UserName/MoinEditorBackup with newtext.

        @param newtext: new text of the page
        @keyword: none used currently
        @rtype: unicode
        @return: url of page backup or None
        """
        # Backup only if set to backup and user has a home page.
        homepage = wikiutil.getHomePage(self.request)
        if not homepage or not self.do_editor_backup:
            return None
        
        _ = self._
        if config.allow_subpages:
            delimiter = "/"
        else:
            delimiter = ""
        backuppage = PageEditor(self.request,
                                homepage.page_name + delimiter + "MoinEditorBackup",
                                do_revision_backup=0)
        if self.cfg.acl_enabled:
            # We need All: at the end to prevent that the original page ACLs
            # make it possible to see preview saves (that maybe were never
            # really saved by the author).
            intro = u"#acl %s:read,write,delete All:\n" % self.request.user.name
        else:
            intro = ""
        pagename = self.page_name
        date = self.request.user.getFormattedDateTime(time.time())
        intro += _('## backup of page "%(pagename)s" submitted %(date)s') % {
            'pagename': pagename, 'date': date,} + u'\n'
        backuppage._write_file(intro + newtext)
        
        return backuppage.url(self.request)
示例#5
0
文件: editlog.py 项目: aahlad/soar
    def getEditorData(self, request):
        """ Return a tuple of type id and string or Page object
            representing the user that did the edit.

            DEPRECATED - try to use getInterwikiEditorData
            NOT USED ANY MORE BY MOIN CODE!

            The type id is one of 'ip' (DNS or numeric IP), 'user' (user name)
            or 'homepage' (Page instance of user's homepage).
        """
        result = 'ip', request.cfg.show_hosts and self.hostname or ''
        if self.userid:
            if self.userid not in self._usercache:
                self._usercache[self.userid] = user.User(
                    request, self.userid, auth_method="editlog:53")
            userdata = self._usercache[self.userid]
            if userdata.name:
                pg = wikiutil.getHomePage(request, username=userdata.name)
                if pg:
                    result = ('homepage', pg)
                else:
                    result = ('user', userdata.name)

        return result