示例#1
0
    def logout(self):
        # expire session
        session_manager = get_session_manager()
        session_manager.expire_session()

        # redirect to index page.
        return redirect(get_path(1) + '/')
示例#2
0
文件: util.py 项目: nascheme/quixote
 def _q_index(self):
     """
     If directory listings are allowed, generate a simple HTML
     listing of the directory's contents with each item hyperlinked;
     if the item is a subdirectory, place a '/' after it. If not allowed,
     return a page to that effect.
     """
     if self.index_filenames:
         for name in self.index_filenames:
             try:
                 obj = self._q_lookup(name)
             except errors.TraversalError:
                 continue
             if (not isinstance(obj, StaticDirectory)
                     and hasattr(obj, '__call__')):
                 return obj()
     if self.list_directory:
         title = 'Index of %s' % quixote.get_path()
         r = TemplateIO(html=True)
         template = htmltext('<a href="%s">%s</a>%s\n')
         r += htmltext('<pre>')
         r += template % ('..', '..', '')
         files = os.listdir(self.path)
         files.sort()
         for filename in files:
             filepath = os.path.join(self.path, filename)
             marker = os.path.isdir(filepath) and "/" or ""
             r += template % (urllib.quote(filename), filename, marker)
         r += htmltext('</pre>')
         body = r.getvalue()
     else:
         title = 'Directory listing denied'
         body = htmltext('<p>This directory does not allow its contents '
                         'to be listed.</p>')
     return errors.format_page(title, body)
示例#3
0
    def logout(self):
        # expire session
        session_manager = get_session_manager()
        session_manager.expire_session()

        # redirect to index page.
        return redirect(get_path(1) + '/')
示例#4
0
 def _q_index(self):
     """
     If directory listings are allowed, generate a simple HTML
     listing of the directory's contents with each item hyperlinked;
     if the item is a subdirectory, place a '/' after it. If not allowed,
     return a page to that effect.
     """
     if self.index_filenames:
         for name in self.index_filenames:
             try:
                 obj = self._q_lookup(name)
             except errors.TraversalError:
                 continue
             if (not isinstance(obj, StaticDirectory)
                     and hasattr(obj, '__call__')):
                 return obj()
     if self.list_directory:
         title = 'Index of %s' % quixote.get_path()
         r = TemplateIO(html=True)
         template = htmltext('<a href="%s">%s</a>%s\n')
         r += htmltext('<pre>')
         r += template % ('..', '..', '')
         files = os.listdir(self.path)
         files.sort()
         for filename in files:
             filepath = os.path.join(self.path, filename)
             marker = os.path.isdir(filepath) and "/" or ""
             r += template % (urllib.parse.quote(filename), filename, marker)
         r += htmltext('</pre>')
         body = r.getvalue()
     else:
         title = 'Directory listing denied'
         body = htmltext('<p>This directory does not allow its contents '
                         'to be listed.</p>')
     return errors.format_page(title, body)
示例#5
0
 def is_dirty(self):
     if False:
         print 'is_dirty %s: has_info=%s dirty=%s' % (get_path(),
                                                      self.has_info(), self.dirty)
     r = (self.has_info() and self.dirty)
     self.dirty = False
     return r
示例#6
0
 def __call__(self):
     if "" in self._q_exports and not quixote.get_request().form:
         # Fix missing trailing slash.
         path = quixote.get_path()
         print "Adding slash to: %r " % path
         return quixote.redirect(path + "/", permanent=True)
     else:
         raise TraversalError(private_msg=('directory %r is not '
                                           'callable' % self))
示例#7
0
 def __call__(self):
     if "" in self._q_exports and not quixote.get_request().form:
         # Fix missing trailing slash.
         path = quixote.get_path()
         print("Adding slash to: %r " % path)
         return quixote.redirect(path + "/", permanent=True)
     else:
         raise TraversalError(private_msg=('directory %r is not '
                                           'callable' % self))
    def keep(self):
        """
        Set the session to persist.
        """
        session = get_session()
        session.keep = True

        # redirect to index page.
        return redirect(get_path(1) + '/')
    def logout(self):
        """
        Expire the session, redirect back to index page.
        """
        # expire session
        session_manager = get_session_manager()
        session_manager.expire_session()

        # redirect to index page.
        return redirect(get_path(1) + '/')
示例#10
0
    def formpostredirect(self):
        """
        Test redirect after a form POST.  This tests a specific bug in
        mechanize...
        """
        request = get_request()

        if not request.form:
            return """\
<form method=POST enctype=multipart/form-data>
<input type=text name=test>
<input type=submit value=submit name=submit>
</form>
"""
        redirect(get_path(1) + '/')
示例#11
0
    def formpostredirect(self):
        """
        Test redirect after a form POST.  This tests a specific bug in
        mechanize...
        """
        request = get_request()

        if not request.form:
            return """\
<form method=POST enctype=multipart/form-data>
<input type=text name=test>
<input type=submit value=submit name=submit>
</form>
"""
        return redirect(get_path(1) + '/')
示例#12
0
 def get_action_url(self):
     action_url = url_quote(get_path())
     query = get_request().get_query()
     if query:
         action_url += "?" + query
     return action_url
示例#13
0
 def get_action_url(self):
     action_url = url_quote(get_path())
     query = get_request().get_query()
     if query:
         action_url += "?" + query
     return action_url
示例#14
0
 def set_dirty(self):
     if False:
         print 'set_dirty %s' % get_path()
     self.dirty = True
 def increment(self):
     session = get_session()
     session.increment()
     return redirect(get_path(1) + '/')