Пример #1
0
 def _q_index(self):
     cookie = get_cookie('user')
     if cookie == 'Peter':
         this_session = get_session()
         this_session.set_user('Peter')
     if not get_user():
         body = Template.Kind_Body % (Template.Kind_Top,"Not Login!","")
         html = Template.HTML % ("Not login!",body)
         return html
     get_response().set_cookie('user','Peter',path='/',expires="Thu 01-Jan-2020 00:00:00 GMT")
     sql = """SELECT * FROM kind"""
     count,res = execute_sql_in_4bbs(sql,"SHOW")
     list = ""
     for e in res:
         list += "<div>"
         list += "Kind_id:<span>" + str(e[0]) + "</span><span>----</span>"
         list += "Kind_name:<span>" + str(e[1]) + "</span><span>----</span>"
         list += "Kind_count:<span>" + str(e[2]) + "</span><span>----</span>"
         list += "Kind_shortname:<span>" + str(e[3]) + "</span><span>----</span>"
         list += '<a href="/kind/delete?kind_id=' + str(e[0]) + '">Delete</a><span>----</span>'
         list += '<a href="/kind/edit?kind_id=' + str(e[0]) + '">Edit</a>'
         list += "</div>"
     body = Template.Kind_Body %(Template.Kind_Top,list,"")
     html = Template.HTML % ("Kind Index",body)
     return html 
Пример #2
0
    def upload_ajax_receive(self):
        request = quixote.get_request()
        print request.form.keys()

        the_file = request.form['file']
        #print dir(the_file)
        #print 'received file with name:', the_file.base_filename
        data = the_file.fp.read()

        #image.add_image(data)
        image.add_image(data, quixote.get_cookie("User") )

        response = quixote.get_response()
        response.set_content_type('image/png')
        #return image.get_latest_image()
        user = quixote.get_cookie("User")
        return image.get_image(user)
Пример #3
0
 def revoke_session_cookie(self):
     """
     Remove the session cookie from the remote user's session by
     resetting the value and maximum age in the response object.  Also
     remove the cookie from the request so that further processing of
     this request does not see the cookie's revoked value.
     """
     cookie_name = self._set_cookie("", max_age=0)
     if get_cookie(cookie_name) is not None:
         del get_request().cookies[cookie_name]
Пример #4
0
 def revoke_session_cookie(self):
     """
     Remove the session cookie from the remote user's session by
     resetting the value and maximum age in the response object.  Also
     remove the cookie from the request so that further processing of
     this request does not see the cookie's revoked value.
     """
     cookie_name = self._set_cookie("", max_age=0)
     if get_cookie(cookie_name) is not None:
         del get_request().cookies[cookie_name]
Пример #5
0
    def _get_session_id(self, config):
        """() -> string

        Find the ID of the current session by looking for the session
        cookie in the request.  Return None if no such cookie or the
        cookie has been expired, otherwise return the cookie's value.
        """
        id = get_cookie(config.session_cookie_name)
        if id == "" or id == "*del*":
            return None
        else:
            return id
Пример #6
0
    def _get_session_id(self, config):
        """() -> string

        Find the ID of the current session by looking for the session
        cookie in the request.  Return None if no such cookie or the
        cookie has been expired, otherwise return the cookie's value.
        """
        id = get_cookie(config.session_cookie_name)
        if id == "" or id == "*del*":
            return None
        else:
            return id
Пример #7
0
 def image_raw(self):
     response = quixote.get_response()
     
     # added for user tracking
     user = quixote.get_cookie("User")
     
     response.set_content_type('image/png')
     
     # img = image.get_latest_image()
     img = image.get_image(user)
     
     return img
Пример #8
0
    def upload_receive(self):
        request = quixote.get_request()

        username = quixote.get_cookie('username')
        the_file = request.form['file']
        print dir(the_file)
        print 'received file with name:', the_file.base_filename
        data = the_file.read(the_file.get_size())

        image.add_image(the_file.base_filename, username, data)

        return quixote.redirect('./')
Пример #9
0
    def upload_receive(self):
        request = quixote.get_request()
        # print request.form.keys()

        the_file = request.form['file']
        # print dir(the_file)
        # print 'received file with name:', the_file.base_filename
        data = the_file.read(int(1e9))
        
#        image.add_image(data)
        image.add_image(data, quixote.get_cookie("User") )
        
        return quixote.redirect('/') # redirects to index
Пример #10
0
    def has_session_cookie(self, must_exist=False):
        """(must_exist : boolean = false) -> bool

        Return true if the request already has a cookie identifying a
        session object.  If 'must_exist' is true, the cookie must
        correspond to a currently existing session; otherwise (the
        default), we just check for the existence of the session cookie
        and don't inspect its content at all.
        """
        config = get_publisher().config
        id = get_cookie(config.session_cookie_name)
        if id is None:
            return False
        if must_exist:
            return self.has_session(id)
        else:
            return True
Пример #11
0
    def has_session_cookie(self, must_exist=False):
        """(must_exist : boolean = false) -> bool

        Return true if the request already has a cookie identifying a
        session object.  If 'must_exist' is true, the cookie must
        correspond to a currently existing session; otherwise (the
        default), we just check for the existence of the session cookie
        and don't inspect its content at all.
        """
        config = get_publisher().config
        id = get_cookie(config.session_cookie_name)
        if id is None:
            return False
        if must_exist:
            return self.has_session(id)
        else:
            return True
Пример #12
0
 def index(self):
     print "User: %s"%(quixote.get_cookie('User'))
     return html.render('index.html')
Пример #13
0
 def find_username(self):
     username = quixote.get_cookie('username')
     if not username:
         username = ''
     return dict(username = username)