當前位置: 首頁>>代碼示例>>Python>>正文


Python Directory.get_session方法代碼示例

本文整理匯總了Python中Directory.get_session方法的典型用法代碼示例。如果您正苦於以下問題:Python Directory.get_session方法的具體用法?Python Directory.get_session怎麽用?Python Directory.get_session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Directory的用法示例。


在下文中一共展示了Directory.get_session方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_comment

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_session [as 別名]
 def send_comment(self, userid, prefix, comment):
   self.lock.acquire()  # only send one comment at a time (since we're hitting multiple rootids)
   try:
     sent_to = {}
     for sessionid, rootid in self.sessions.items():
       # get the session; if the session has expired, remove and move on
       session = Directory.get_session(sessionid)
       if not session:
         del self.sessions[sessionid]
         continue
         
       # if we've already sent to this rootid, skip and move on
       if sent_to.has_key(rootid):
         continue
       sent_to[rootid] = rootid
       
       # find the actual parent of this comment
       root = datagate.get_item(rootid)
       if not root:
         print "RatingProxy couldn't find rootid:", rootid
         continue
       parentid = self.find_parent(root, prefix) or rootid
       
       # create and send the event to the system (goes to all interested users)
       # I'm using a blank windowid so it goes to anyone looking at this rootid
       item = datagate.create_item(parentid=parentid, creatorid=userid)
       item.text = comment
       item.save()
       event = BaseView.views['rating']._create_event(item, 'processAdd')
       Events.send_event(rootid, event)
   
   finally:
     self.lock.release()
開發者ID:ssaltzman,項目名稱:POET,代碼行數:35,代碼來源:RatingProxy.py

示例2: log_it

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_session [as 別名]
 def log_it(self, request):
   '''Logs the information in a request'''
   # first create the request
   info = []
   info.append('Date: ' + time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))
   session = Directory.get_session(request.getvalue('z', ''))
   if session and session.user:
     info.append('User: ' + session.user.username)
   for key in request.form.keys():
     info.append(key + ": " + str(request.getvalue(key)))
   
   # log to the file
   log_sync_lock.acquire()
   try:
     f = open(Constants.REQUEST_LOG_FILE, 'a')
     f.write('\n'.join(info) + '\n\n')
     f.close()
   finally:
     log_sync_lock.release()
開發者ID:ssaltzman,項目名稱:POET,代碼行數:21,代碼來源:run_cmd.py

示例3: handle_cgi_request

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_session [as 別名]
    def handle_cgi_request(self):
        """Handles a cgi request.  This is the main entry point for client requests,
       whether POST or GET, that are cgi-bin requests.  They all share the
       same memory space (i.e. this singleton object)."""

        # parse the form parameters to the form object
        # if a post request, encode everything (post requests can't encode on the client side because they come from forms)
        # get requests should encode on the client side (to handle special characters in the URL)
        if self.method.lower() == "get":
            for item in self.form.list:
                item.value = Constants.decode(item.value)

        # set the window id
        self.windowid = self.getvalue("global_windowid")

        # send the headers
        self.send_headers()

        try:

            # get the view
            viewst = self.getvalue("global_view", "meetingchooser").lower()

            # get the session, if there is one
            self.session = Directory.get_session(self.form.getvalue("z", ""))

            # if session is none, try logging the user in based upon their username and password parameters
            if self.session == None:
                self.session = Directory.login(self.form.getvalue("username", ""), self.form.getvalue("password", ""))

            # if the view is login, log the session out
            if (viewst == "login" or viewst == "logout") and self.session != None:
                Directory.logout(self.session)
                self.session = None

            # if session is still None, send them to the login page
            if self.session == None:
                viewst = "login"

            # process actions
            if self.session:
                Events.process_actions(self)

            # send events xml or send to view processing
            if self.getvalue("gm_internal_action") == "send_events_xml":
                Events.send_events_xml(self)

            else:
                # get the view
                if not BaseView.views.has_key(viewst):
                    self.writeln("<html><body>Error!  No view named " + viewst + " found.</body></html>")
                    return
                view = BaseView.views[viewst]
                self.view = view

                # send processing to the view
                Constants.log.debug("Sending processing to view: " + viewst)
                view.handle_request(self, viewst)

        except:
            self.writeln("<html><body>")
            self.writeln("<hr>")
            self.writeln("<b>The following error has occurred in the GroupMind application:</b>")
            self.writeln("<pre><tt>")
            traceback.print_exc(file=self.out)
            traceback.print_exc()
            self.writeln("</pre></tt>")
            self.writeln("</body></html>")
開發者ID:ssaltzman,項目名稱:POET,代碼行數:70,代碼來源:GroupMind.py

示例4: clearsession_action

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_session [as 別名]
 def clearsession_action(self, request):
   session = Directory.get_session(request.getvalue('sessionid'))
   Directory.logout(session)
開發者ID:ssaltzman,項目名稱:POET,代碼行數:5,代碼來源:Sessions.py


注:本文中的Directory.get_session方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。