Ejemplo n.º 1
0
    def _getSid(self):
        """figures out which session id to use"""

        sid = None

        # first try to get the sid from the browser..
        for mode in (self.mode, self.fallbackMode):
            if sid is None:
                try:
                    if mode == "cookie":
                        sid = self._request.cookie[self.name]
                    elif mode == "get":
                        sid = self._request.query[self.name]
                    else:
                        raise "Unknown mode: " + mode
                except KeyError:
                    pass

        # if that didn't work, just make one up..
        if sid is None:
            import weblib
            sid = weblib.uid()

        #@TODO: add code for timeouts wrt setCookie
        if self.mode == "cookie":
            # always update the cookie
            self._response.addCookie(self.name, sid)

        return sid
Ejemplo n.º 2
0
    def _getSid(self):
        """figures out which session id to use"""

        sid = None
        
        # first try to get the sid from the browser..
        for mode in (self.mode, self.fallbackMode):
            if sid is None:
                try:
                    if mode == "cookie":
                        sid = self._request.cookie[self.name]
                    elif mode == "get":
                        sid = self._request.query[self.name]
                    else:
                        raise "Unknown mode: " + mode
                except KeyError:
                    pass

        # if that didn't work, just make one up..
        if sid is None:
            import weblib
            sid = weblib.uid()

        #@TODO: add code for timeouts wrt setCookie
        if self.mode == "cookie":
            # always update the cookie
            self._response.addCookie(self.name, sid)
                
        return sid
Ejemplo n.º 3
0
 def save(self):
     if not self.username:
         raise ValueError, "username is requied."
     self.__super.save(self)
     self._userRec["ID"]=self.ID
     if not self.uid:
         import weblib
         self.uid = weblib.uid()
     self._userRec.save()