コード例 #1
0
    def setUp(self):
        app = web.auto_application()
        session = self.make_session(app)

        class count(app.page):
            def GET(self):
                session.count += 1
                return str(session.count)

        class reset(app.page):
            def GET(self):
                session.kill()
                return ""

        class redirect(app.page):
            def GET(self):
                session.request_token = "123"
                raise web.redirect("/count")

        class get_session(app.page):
            path = "/session/(.*)"

            def GET(self, name):
                return session[name]

        self.app = app
        self.session = session
コード例 #2
0
ファイル: test_session.py プロジェクト: SaimenTse/vhub
    def setUp(self):
        app = web.auto_application()
        session = self.make_session(app)
        class count(app.page):
            def GET(self):
                session.count += 1
                return str(session.count)

        class reset(app.page):
            def GET(self):
                session.kill()
                return ""

        class redirect(app.page):
            def GET(self):
                session.request_token = '123'
                raise web.redirect('/count')

        class get_session(app.page):
            path = "/session/(.*)"
            def GET(self, name):
                return session[name]

        self.app = app
        self.session = session
コード例 #3
0
ファイル: auth.py プロジェクト: phoracek/webpy-modules
 def setUp(self):
     webmod.config.auth.crypt = self.crypt
     self.app = web.auto_application()
     try:
         self.remove_database()
     except:
         pass
     self.db = self.make_database()
コード例 #4
0
ファイル: session.py プロジェクト: Ju2ender/watchdog
 def setUp(self):
     app = web.auto_application()
     session = self.make_session(app)
     class count(app.page):
         def GET(self):
             session.count += 1
             return str(session.count)
     
     class reset(app.page):
         def GET(self):
             session.kill()
             return ""
             
     self.app = app
     self.session = session
コード例 #5
0
 def setUp(self):
     app = web.auto_application()
     session = self.make_session(app)
     class count(app.page):
         def GET(self):
             session.count += 1
             return str(session.count)
     
     class reset(app.page):
         def GET(self):
             session.kill()
             return ""
             
     self.app = app
     self.session = session
コード例 #6
0
ファイル: webapp.py プロジェクト: hw233/twisted_zdzl
def init():
    """ web.py 设定 - 开始 """
    global app, render, template_render, api_url, snss
    global aes_encrypt

    from model import logon_store
    from game.store.define import (GF_webUrl, GF_SDK91_APP_ID,
                                   GF_SDK91_APP_KEY, GF_SDK91_URLS,
                                   GF_DPAY_APP_ID, GF_DPAY_APP_KEY,
                                   GF_DPAY_URLS, GF_CLIENTRPC_AESKEY)

    web.config['debug'] = web_config.auto_reload
    app = web.auto_application()
    web.config.session_parameters['timeout'] = 60 * 10  #缓存有效时间
    use_cache = web_config.use_cache
    loc = web_config.templates_path
    log.info('templates_path:%s', loc)
    base_layout = 'backstage/layout'
    session_initializer = {"login": 0, "name": None}
    globals_dict = {
        'hasattr': hasattr,
    }
    render = web.template.Render(cache=use_cache, loc=loc)
    template_render = web.template.Render(cache=use_cache,
                                          loc=loc,
                                          base=base_layout,
                                          globals=globals_dict)
    log.debug(u'web参数:templates_path=%s, static_path=%s', loc,
              web_config.static_path)

    api_url = logon_store.get_config(GF_webUrl)

    #初始化sns模块
    from game import Game
    snss = Game.init_snss(get_config=logon_store.get_config,
                          web_app=app,
                          api_url=api_url,
                          res_store=logon_store)

    from corelib.aes import new_aes_encrypt
    key = logon_store.get_config(GF_CLIENTRPC_AESKEY)
    aes_encrypt = new_aes_encrypt(key)
コード例 #7
0
ファイル: config.py プロジェクト: vitalyvolkov/metapolator
    try:
        return handler()
    except web.HTTPError:
        web.ctx.orm.commit()
        raise

    except:
        web.ctx.orm.rollback()
        raise
    finally:
        web.ctx.orm.commit()
        # If the above alone doesn't work, uncomment
        # the following line:
        #web.ctx.orm.expunge_all()

app = web.auto_application()
app.add_processor(load_sqla)


session = web.session.Session(app, web.session.DiskStore('sessions'),
                              {'count': 0})
app.add_processor(load_user)


def is_loggedin():
    try:
        return web.ctx.user
    except AttributeError:
        pass

コード例 #8
0
import re
import httplib
import shutil
import glob
from tempfile import mkstemp, mkdtemp
from datetime import datetime
from zipfile import ZipFile
from random import randint

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import web

import plistlib
from log import log

app = web.auto_application()


def safejoin(base, *pn):
    joined = []
    for p in pn:
        joined.append(p.strip("./"))
    return os.path.join(base, *joined)


class Browse(app.page):
    path = "/browse(/.+)?"

    def GET(self, root):
        #print root
        if not root:
コード例 #9
0
ファイル: application.py プロジェクト: Rainfall/PostToWiki
#! /usr/bin/python

import web

rtool = web.auto_application()

コード例 #10
0
ファイル: mobile.py プロジェクト: m1993619/gratuation
#!/usr/bin/env python
#encoding=utf-8
import os
import web
import json
import time
import pg
import utils
import decimal
import datetime
import traceback
from auth import *

from render import rendeHtml

mobile_app = web.auto_application()


class ExtendedEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, datetime.datetime):
            # If it's a date, convert to a string
            # Replace this with whatever your preferred date format is
            return o.strftime("%Y-%m-%d %H:%M")
        elif isinstance(o, datetime.date):
            return o.strftime('%Y-%m-%d')
        elif isinstance(o, decimal.Decimal):
            return int(o)
        # Defer to the superclass method
        return json.JSONEncoder(self, o)