当前位置: 首页>>代码示例>>Python>>正文


Python Cookie.get_cookies方法代码示例

本文整理汇总了Python中mod_python.Cookie.get_cookies方法的典型用法代码示例。如果您正苦于以下问题:Python Cookie.get_cookies方法的具体用法?Python Cookie.get_cookies怎么用?Python Cookie.get_cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mod_python.Cookie的用法示例。


在下文中一共展示了Cookie.get_cookies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
    def init(self):
        
        # Parse the HTTP headers for variables and files.
        for field in self.__field_storage.list:
            
            # This is a normal variable.
            if str(type(field.file)) == "<type 'cStringIO.StringI'>" or \
                str(type(field.file)) == "<type 'cStringIO.StringO'>":
                    self.set_var(field.name, field.value)
                
            # This is a file.
            else:
                # Some browsers give a full path instead of a file name. Some
                # browsers give an encoded file name. Plan for those cases.
                # FIXME: is the explanation above and the code below correct?
                filename = field.filename
                filename = urllib.unquote_plus(filename) # unquote filename (it should be encoded like an url)
                filename = re.sub(r'\\+', '/', filename) # some OS use "\" for paths... replace '\' in '/'
                filename = os.path.basename(filename) # some browsers (IE) send full path.. rip path part and just get file name
                self.__files[field.name] = KWebFile(filename, field.file)
        
        # Store the HTTP headers.
        for key in self.__req.headers_in:
            self.__headers_in[key] = self.__req.headers_in[key]

        # Initialize the cookies.
        self.__cookies_in = Cookie.get_cookies(self.__req)
开发者ID:fdgonthier,项目名称:teambox-core,代码行数:29,代码来源:kweb_mp.py

示例2: __init__

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
 def __init__(self,req=None, form=None):
     self.req = req
     if self.req != None:
         # mod_python
         self.form = util.FieldStorage(self.req)
         self._cookies_in = Cookie.get_cookies(self.req)
     else:
         # if we have a form, don't get a new one
         if form:
            self.form=form
         # if we don't have a form, then get one
         else:
            self.form = cgi.FieldStorage()
         self._cookies_in = SimpleCookie()
         try:
             self._cookies_in.load(os.environ["HTTP_COOKIE"])
         except KeyError:
             pass
     self._dispatch      = {}
     self._header_sent   = 0
     self._header_props  = {"Content-Type" : "text/html;charset=UTF-8"}
     self._header_props  = {}
     self._header_type   = "header"
     self._cookies       = []
     self._url           = ""
     self._environ       = os.environ
     self.template_dir   = 'templates'
     self.run_mode_param = 'rm'
     self.start_mode     = ''
     self.__globals__    = {}
     self.setup()
开发者ID:thecapn2k5,项目名称:cloneme,代码行数:33,代码来源:cgi_app.py

示例3: get_cookie

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
 def get_cookie(cls, req, name):
     """Retreive cookie by name from request object."""
     #cookies = mod_python.Cookie.get_cookies(req)
     cookies = Cookie.get_cookies(req)
     this_cookie = cookies.get(name)
     value = cut(str(this_cookie), "{0}=".format(name))
     return value
开发者ID:OaklandPeters,项目名称:local_packages,代码行数:9,代码来源:web_utility.py

示例4: __init__

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
 def __init__(self, req):
     """get, extract info, and do upkeep on the session cookie. This determines what the sessid and user are 
          for this request."""
     #pass the request in making in so we can edit it later if requested (ACL for example)
     self.ip = req.connection.remote_ip
     c = Cookie.get_cookies(req)
     if not c.has_key('mps'):
         self.sessid = Uid().new_sid(req)
     else:
         c = c['mps']
         self.sessid = c.value
         
     #make new cookie so the cycle continues
     c = Cookie.Cookie('mps', self.sessid)
     c.path = '/'
     Cookie.add_cookie(req, c)
     
     self.session_path = "%s%s"%(path_to_sessions, self.sessid)
     self.full_session_path = "%s%s"%(self.session_path, db_extension)
     
     #use previous authenication until cookie is reevaluated, if they are officially logged in (in Instance)
     if os.path.exists(self.full_session_path):
         session = shelve.open(self.session_path, 'rw')
         self.user  = session['USER_']
         session.close()
     else:
         self.user = self.unauthorized
开发者ID:circlecycle,项目名称:mps,代码行数:29,代码来源:Identity.py

示例5: general_authenhandler

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def general_authenhandler(req, req_type, anon_ok=False):
	pw = req.get_basic_auth_pw()
	cookies = Cookie.get_cookies(req)
	if not cookies.has_key('csrftoken'):
		cookie = Cookie.Cookie('csrftoken', hashlib.md5(str(random.randrange(0, 2<<63))).hexdigest())
		cookie.path = '/'
		if config.get('session', 'cookie_host') != '':
			cookie.domain = config.get('session', 'cookie_host')
		Cookie.add_cookie(req, cookie)
	if cookies.has_key('myemsl_session'):
		sql = "select user_name from myemsl.eus_auth where session_id = %(sid)s"
		cnx = myemsldb_connect(myemsl_schema_versions=['1.0'])
		cursor = cnx.cursor()
		cursor.execute(sql, {'sid':cookies['myemsl_session'].value})
		rows = cursor.fetchall()
		found = False
		for row in rows:
			req.user = row[0]
			found = True
		if found:
			logger.debug("Session: %s", str(cookies['myemsl_session'].value))
#FIXME outage_check seems to be in the wrong place for a myemsl database outage.
			return outage_check(req, req_type)
	elif anon_ok:
		req.user = ''
		return outage_check(req, req_type)
	url = urllib.quote(req.unparsed_uri)
	redirect(req, "/myemsl/auth?url=%s" %(url))
	return apache.HTTP_UNAUTHORIZED
开发者ID:EMSL-MSC,项目名称:pacifica-2.0,代码行数:31,代码来源:__init__.py

示例6: accesshandler

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def accesshandler(request):

    cookies = Cookie.get_cookies(request)

    # if login ticket cookie does not exist, then deny
    if not cookies.has_key('login_ticket'):
        # just refuse access
        return apache.HTTP_FORBIDDEN

    ticket = cookies['login_ticket'].value
    if not ticket:
        return apache.HTTP_FORBIDDEN

    server = TacticServerStub.get(protocol='local')
    expr = "@SOBJECT(sthpw/ticket['ticket','%s'])" % ticket
    sobject = server.eval(expr, single=True)
    now = SPTDate.now()
    expiry = sobject.get("expiry")
    if expiry and expiry < str(now):
        return apache.HTTP_FORBIDDEN

    request.add_common_vars()
    path = str(request.subprocess_env['REQUEST_URI'])
    if path == None:
        return apache.HTTP_FORBIDDEN


    # FIXME: find some mechanism which is more acceptable ... like /icons
    #if path.find("_icon_") != -1:
    #    return apache.OK

    return apache.OK
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:asset_security.py

示例7: logout

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def logout(req):
    cookies = Cookie.get_cookies(req)
    Cookie.add_cookie(req, 'ogtvogh', '', expires=time.time(), path='/')
    req.status=apache.HTTP_MOVED_TEMPORARILY
    req.headers_out["Location"] = SITEURL
    req.send_http_header()
    return "You have successfully logged out"
开发者ID:doublewera,项目名称:smdc,代码行数:9,代码来源:structure.py

示例8: __init__

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
 def __init__(self,req,appid=None):
     self.req = req
     if appid == None:
         args = split_args(self.req.args);
         appid = args['APPID']
     self.captureSettings = load_capture_settings(self.req,appid)
     self.cookie = Cookie.get_cookies(self.req, Cookie.MarshalCookie, secret=str(self.captureSettings["secretKey"]))
开发者ID:untangle,项目名称:ngfw_src,代码行数:9,代码来源:handler.py

示例9: _add_csrf_cookie_if_needed

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def _add_csrf_cookie_if_needed(req):
    signed_cookies = Cookie.get_cookies(req, Cookie.SignedCookie, secret=_get_secret())
    cookie = signed_cookies.get(settings.csrf_cookie_name, None)
    if cookie:
        # make sure we aren't altered
        if type(cookie) is Cookie.SignedCookie and cookie.value == _message_contents():
            return
    Cookie.add_cookie(req, _generate_csrf_cookie())
开发者ID:JonnyFunFun,项目名称:pycoin-gateway,代码行数:10,代码来源:csrf.py

示例10: get_cookie

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
 def get_cookie(my, name):
     cookies = Cookie.get_cookies(my.request)
     cookie = cookies[name]
     if cookie == None:
         return ""
     else:
         my.error("cookie: "+cookie.value)
         return cookie.value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:mod_python_wrapper.py

示例11: isValidSession

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def isValidSession(req):
    """
    check the Django's session table to decided this is a valid session or not.
    """

    # check for PythonOptions
    _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes')

    options = req.get_options()
    permission_name = options.get('DjangoPermissionName', None)
    staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on"))
    superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off"))
    settings_module = options.get('DJANGO_SETTINGS_MODULE', None)
    if settings_module:
        os.environ['DJANGO_SETTINGS_MODULE'] = settings_module

    from django.conf import settings
    cookieName = settings.SESSION_COOKIE_NAME

    cookies = Cookie.get_cookies(req)
    if not cookies.has_key(cookieName):
        return False

    #import pdb; pdb.set_trace()
    sessionId = cookies[cookieName].value

    # mod_python fakes the environ, and thus doesn't process SetEnv.  This fixes
    # that so that the following import works
    os.environ.update(req.subprocess_env)

    from django.contrib.sessions.models import Session
    from django import db
    db.reset_queries()

    try:
        try:
            session = Session.objects.get(pk=sessionId)
        except Session.DoesNotExist:
            return False

        sessionData = session.get_decoded()
        if not sessionData.has_key('_auth_user_id'):
            # this is not a valid session!
            return False

        if session.expire_date > datetime.now():
            if isResourcesRequest(req):
                # just pass
                return True
            # this is a valid session, update the expre date!
            expiry = settings.SESSION_COOKIE_AGE
            session.expire_date = datetime.now() + timedelta(seconds=expiry)
            session.save()
            return True
        else:
            return False
    finally:
        db.connection.close()
开发者ID:dallakyan,项目名称:leocornus.django.ploneproxy,代码行数:60,代码来源:modpython.py

示例12: get_session_info

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
    def get_session_info(self):
        """    checks to see if the user is logged in, via the session cookie.
        """
        
        cookies = Cookie.get_cookies(self.req)

        if not cookies.has_key('sessionkey'):
            return None

        return cookies['sessionkey'].value
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:12,代码来源:zct.py

示例13: authorize

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def authorize(req):
    cookies = Cookie.get_cookies(req)
    if cookies.has_key("ogtvogh"):
        user = str(cookies["ogtvogh"]).split('=')[1]
        f = open('/etc/apache2/passwords')
        for line in f:
            if user == line.split(':')[1]:
                f.close()
                return 'auth'
    return ''
开发者ID:doublewera,项目名称:smdc,代码行数:12,代码来源:structure.py

示例14: index

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def index(req):
    secret = 'my_secret'
    marshal_cookies = Cookie.get_cookies(req, Cookie.MarshalCookie, secret=secret)
    returned_marshal = marshal_cookies.get('marshal', None)
    if(returned_marshal):
        returned_marshal.expires= time.time()
        Cookie.add_cookie(req, returned_marshal)
        return '<html><body>return to main place <a href="./">here</a></body></html>'
    else:
        return '<html><title></title><body>there is nothing <a href="./">back</a></body></html>'
开发者ID:COMU,项目名称:pyldapadmin,代码行数:12,代码来源:server_info.py

示例15: _check_csrf

# 需要导入模块: from mod_python import Cookie [as 别名]
# 或者: from mod_python.Cookie import get_cookies [as 别名]
def _check_csrf(req):
    signed_cookies = Cookie.get_cookies(req, Cookie.SignedCookie, secret=_get_secret())
    cookie = signed_cookies.get(settings.csrf_cookie_name, None)
    if cookie:
        # make sure we aren't altered
        if type(cookie) is not Cookie.SignedCookie or cookie.value != _message_contents():
            raise apache.SERVER_RETURN, apache.HTTP_NOT_ACCEPTABLE
    else:
        return False
    return True
开发者ID:JonnyFunFun,项目名称:pycoin-gateway,代码行数:12,代码来源:csrf.py


注:本文中的mod_python.Cookie.get_cookies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。