• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python web.unloadhook函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中web.unloadhook函数的典型用法代码示例。如果您正苦于以下问题:Python unloadhook函数的具体用法?Python unloadhook怎么用?Python unloadhook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: init_app

def init_app():
    app = web.application(urls, globals())
    #app.notfound = api_notfound
    #app.internalerror = api_internalerror
    app.add_processor(web.loadhook(api_loadhook))
    app.add_processor(web.unloadhook(api_unloadhook))    
    return app
开发者ID:gaotianpu,项目名称:todolist,代码行数:7,代码来源:api.py


示例2: __init__

    def __init__(self, mapping, fvars):

        # Parent constructor
        web.application.__init__(self, mapping, fvars) #@UndefinedVariable

        # The views are bound once for all to the configuration
        config.views = web.template.render("app/views/", globals={
            "all_seasons": lambda: Season.all(),
            "all_polls": lambda: Poll.all(),
            "webparts": webparts,
            "formatting": formatting,
            "dates": dates,
            "zip": zip,
            "getattr": getattr,
            "hasattr": hasattr,
            "class_name": lambda x: x.__class__.__name__,
            "namedtuple": collections.namedtuple,
            "config": config,
            "result_statuses": Result.STATUSES,
            "Events": Events
        })

        # The ORM is bound once since it dynamically loads the engine from the configuration
        config.orm = meta.init_orm(lambda : config.engine)

        # Binds the hooking mechanism & the SQL Alchemy processor
        self.add_processor(web.loadhook(http.init_hooks))
        self.add_processor(web.unloadhook(http.execute_hooks))        
        self.add_processor(http.sqlalchemy_processor)

        # Binds the webparts initialization mechanism
        self.add_processor(web.loadhook(webparts.init_webparts))
开发者ID:franck260,项目名称:vpt,代码行数:32,代码来源:application.py


示例3: testUnload

    def testUnload(self):
        x = web.storage(a=0)

        urls = ("/foo", "foo", "/bar", "bar")

        class foo:
            def GET(self):
                return "foo"

        class bar:
            def GET(self):
                raise web.notfound()

        app = web.application(urls, locals())

        def unload():
            x.a += 1

        app.add_processor(web.unloadhook(unload))

        app.request("/foo")
        self.assertEquals(x.a, 1)

        app.request("/bar")
        self.assertEquals(x.a, 2)
开发者ID:hyh626,项目名称:webpy,代码行数:25,代码来源:application.py


示例4: setup

def setup():
    import home, inlibrary, borrow_home, libraries, stats, support, events, status, merge_editions, authors
    
    home.setup()
    inlibrary.setup()
    borrow_home.setup()
    libraries.setup()
    stats.setup()
    support.setup()
    events.setup()
    status.setup()
    merge_editions.setup()
    authors.setup()
    
    import api
    api.setup()
    
    from stats import stats_hook
    delegate.app.add_processor(web.unloadhook(stats_hook))
    
    if infogami.config.get("dev_instance") is True:
        import dev_instance
        dev_instance.setup()

    setup_template_globals()
    setup_logging()
    logger = logging.getLogger("openlibrary")
    logger.info("Application init")
开发者ID:iambibhas,项目名称:openlibrary,代码行数:28,代码来源:code.py


示例5: setup

def setup():
    import home, inlibrary, borrow_home, libraries, stats, support, \
        events, status, merge_editions, authors

    home.setup()
    inlibrary.setup()
    borrow_home.setup()
    libraries.setup()
    stats.setup()
    support.setup()
    events.setup()
    status.setup()
    merge_editions.setup()
    authors.setup()

    import api
    from stats import stats_hook
    delegate.app.add_processor(web.unloadhook(stats_hook))

    if infogami.config.get("dev_instance") is True:
        import dev_instance
        dev_instance.setup()

    setup_context_defaults()
    setup_template_globals()
开发者ID:randomecho,项目名称:openlibrary,代码行数:25,代码来源:code.py


示例6: setup

def setup():
    from openlibrary.plugins.openlibrary import (home, inlibrary, borrow_home, libraries,
                                                 stats, support, events, design, status,
                                                 merge_editions, authors)

    home.setup()
    design.setup()
    inlibrary.setup()
    borrow_home.setup()
    libraries.setup()
    stats.setup()
    support.setup()
    events.setup()
    status.setup()
    merge_editions.setup()
    authors.setup()

    from openlibrary.plugins.openlibrary import api
    delegate.app.add_processor(web.unloadhook(stats.stats_hook))

    if infogami.config.get("dev_instance") is True:
        from openlibrary.plugins.openlibrary import dev_instance
        dev_instance.setup()

    setup_context_defaults()
    setup_template_globals()
开发者ID:hornc,项目名称:openlibrary-1,代码行数:26,代码来源:code.py


示例7: __new__

  def __new__(cls, *args, **kwargs):
    app = web.application(*args, **kwargs)

    app.add_processor(web.loadhook(cls._connect))
    app.add_processor(web.unloadhook(cls._disconnect))

    return app
开发者ID:AmitShah,项目名称:numenta-apps,代码行数:7,代码来源:__init__.py


示例8: test_hook

 def test_hook(self):
     app.add_processor(web.loadhook(before))
     app.add_processor(web.unloadhook(after))
    
     self.assertEqual(app.request('/hello').data, 'yx')
     global str
     self.assertEqual(str, 'yxz')
开发者ID:492852238,项目名称:SourceLearning,代码行数:7,代码来源:myapplication.py


示例9: set_webpy_hooks

 def set_webpy_hooks(self, app, shutdown, rollback):
     try:
         import web
     except ImportError:
         return
     if not hasattr(web, 'application'):
         return
     if not isinstance(app, web.application):
         return
     app.processors.append(0, web.unloadhook(shutdown))
开发者ID:oneek,项目名称:sqlalchemy-wrapper,代码行数:10,代码来源:main.py


示例10: setup

def setup():
    import home, inlibrary, borrow_home, libraries
    
    home.setup()
    inlibrary.setup()
    borrow_home.setup()
    libraries.setup()
    
    from stats import stats_hook
    delegate.app.add_processor(web.unloadhook(stats_hook))
    
    setup_template_globals()
开发者ID:strogo,项目名称:openlibrary,代码行数:12,代码来源:code.py


示例11: set_webpy_hooks

 def set_webpy_hooks(self, app, shutdown, rollback):
     """Setup the webpy-specific ``web.unloadhook`` to call
     ``db.session.remove()`` after each response.
     """
     try:
         import web
     except ImportError:
         return
     if not hasattr(web, 'application'):
         return
     if not isinstance(app, web.application):
         return
     app.processors.append(0, web.unloadhook(shutdown))
开发者ID:1gnatov,项目名称:sqlalchemy-wrapper,代码行数:13,代码来源:main.py


示例12: createprocessor

def createprocessor():
	createsession()
	def pre_hook():
		mylog.loginfo()
	app.add_processor(web.loadhook(pre_hook))
	def post_hook():
		if web.ctx.fullpath[0:6] == "/rest/": 
				if web.ctx.fullpath[6:14] != "resource" \
						and web.ctx.fullpath[6:11] != "photo":
							web.header("content-type", "application/json")
				else:
					return
		else:
			web.header("content-type", "text/html; charset=utf-8")
	app.add_processor(web.unloadhook(post_hook))
开发者ID:blueskyz,项目名称:miniBlog,代码行数:15,代码来源:myweb.py


示例13: globals

    "/([^/]*)/reindex", "reindex",    
    "/([^/]*)/new_key", "new_key",
    "/([^/]*)/things", "things",
    "/([^/]*)/versions", "versions",
    "/([^/]*)/write", "write",
    "/([^/]*)/account/(.*)", "account",
    "/([^/]*)/permission", "permission",
    "/([^/]*)/log/(\d\d\d\d-\d\d-\d\d:\d+)", 'readlog',
    "/_invalidate", "invalidate"
)

app = web.application(urls, globals(), autoreload=False)

app.add_processor(web.loadhook(setup_remoteip))
app.add_processor(web.loadhook(cache.loadhook))
app.add_processor(web.unloadhook(cache.unloadhook))

def process_exception(e):
    if isinstance(e, common.InfobaseException):
        status = e.status
    else:
        status = "500 Internal Server Error"

    msg = str(e)
    raise web.HTTPError(status, {}, msg)
    
class JSON:
    """JSON marker. instances of this class not escaped by jsonify.
    """
    def __init__(self, json):
        self.json = json
开发者ID:termim,项目名称:infogami,代码行数:31,代码来源:server.py


示例14: rot

		"""
	#global session
	#session = s

if __name__ == "__main__":
	
	curdir = os.path.dirname(__file__)
	curdir=""
	web.config.debug = config.web_debug
	#web.config.debug = False
	
	app = rot(webctx.urls, globals())
	init_session(app)
	
	app.add_processor(web.loadhook(loadhook))
	app.add_processor(web.unloadhook(unloadhook))
	
	# web.myapp = app
	# web.init_session = init_session
	
	app.run(config.port, "0.0.0.0", Log)
else:
	
	web.config.debug = config.web_debug
	app = web.application(webctx.urls, globals())
	init_session(app)
	
	app.add_processor(web.loadhook(loadhook))
	app.add_processor(web.unloadhook(unloadhook))
	
	# web.myapp = app
开发者ID:wunderlins,项目名称:rot,代码行数:31,代码来源:httpd.py


示例15: service

"""
try:
	webctx.session
except NameError:
	web.debug("Resetting session ...")
	webctx.session = None
"""

app = None
if __name__ == "__main__":
	web.config.debug = False

	app = service(urls, globals())
	# session setup, make sure to call it only once if in debug mode
	init_session(app)
	
	app.add_processor(web.loadhook(hooks.load))
	app.add_processor(web.unloadhook(hooks.unload))

	#webctx.session["pid"] += 1
	#print "starting ..."
	#app.add_processor(web.loadhook(loadhook))
	#app.add_processor(web.unloadhook(unloadhook))
	#app.run(config.port, "0.0.0.0")
	
	#webctx.session = get_session(app)

	app.run(config.port, "0.0.0.0", Log)


开发者ID:samuelpulfer,项目名称:docverwaltung,代码行数:28,代码来源:httpd.py


示例16: ManagedConnectionWebapp

      yield packer.pack(names)
      for row in result:
        resultTuple = (
            row.uid,
            calendar.timegm(row.created_at.timetuple()),
            calendar.timegm(row.agg_ts.timetuple()),
            row.text,
            row.username,
            row.userid
          )
        yield packer.pack(resultTuple)
    else:
      results = {"names": ["uid", "created_at", "agg_ts", "text", "username",
                           "userid"],
                 "data": [(row.uid,
                           row.created_at.strftime("%Y-%m-%d %H:%M:%S"),
                           row.agg_ts.strftime("%Y-%m-%d %H:%M:%S"),
                           row.text,
                           row.username,
                           row.userid) for row in result]}
      self.addStandardHeaders()
      yield utils.jsonEncode(results)



app = ManagedConnectionWebapp(urls, globals())
app.add_processor(web.loadhook(_connect))
app.add_processor(web.unloadhook(_disconnect))

开发者ID:maparco,项目名称:numenta-apps,代码行数:28,代码来源:tweets_api.py


示例17: my_unloadhook

    def my_unloadhook():
        print "my unload hook"

        app.add_processor(web.loadhook(my_loadhook))
        app.add_processor(web.unloadhook(my_unloadhook))
开发者ID:lerry,项目名称:My-Photo-Lib,代码行数:5,代码来源:_base.py


示例18: feeder_loadhook

	if False != session.set_flash:
		session.flash = session.set_flash
		session.set_flash = False
	if False != session.set_error_flash:
		session.error_flash = session.set_error_flash
		session.set_error_flash = False

def feeder_loadhook ():
	session.feeder = feeder.is_alive()

def flash_unloadhook ():
	session.flash = False
	session.error_flash = False

app.add_processor( web.loadhook( permission_loadhook ) )
app.add_processor( web.loadhook( flash_loadhook ) )
app.add_processor( web.loadhook( feeder_loadhook ) )
app.add_processor( web.unloadhook( flash_unloadhook ) )

####### Start the Feeder #######

feeder = Process( target=smf.feeder.run, args=( constants.DEFAULT_CONFIG, ) )
feeder.daemon = True
feeder.start()

####### Start the Server #######
try:
	app.run()
except Exception, e:
	feeder.terminate()
	feeder.join()
开发者ID:jmhobbs,项目名称:simple-mail-feeder,代码行数:31,代码来源:server.py


示例19: Connection

    if web.ctx.status == '200 OK' and accept and not pattern.search(accept):
        web.header('Content-Type', 'text/xml')
    
urls = (
    '/?', 'Service',
    '/category', 'Category',
    '/collection/(.*)', 'Collection',
    '/document/(.*)', 'Document',
)

connection = Connection()
db_name = 'test' if sys.argv[-1] == '--test' else 'test_database'
db = connection[db_name]
app_atom = web.application(urls, locals())
app_atom.add_processor(web.unloadhook(my_unloadhook))

class Service:
    def GET(self):
        """
        Returns a service entity conforming to RFC ...
        >>> req = app_atom.request('/', method='GET')
        >>> req.status
        '200 OK'
        >>> req.headers['Content-Type']
        'application/atomsvc+xml;charset=\"utf-8\"'
        """
        collections = []        
        for name in db.collection_names():
            if not name == 'system.indexes':
                collections.append(E.collection(
开发者ID:freudenberg,项目名称:atomicblog,代码行数:30,代码来源:atom.py


示例20: header

        header('Content-Type', 'application/x-json-stream')
        try:
            params = parse_response(json_data)
            if 'pfns' in params:
                pfns = params['pfns']
            if 'rse' in params:
                rse = params['rse']
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list')

        try:
            declare_bad_file_replicas(rse=rse, pfns=pfns, issuer=ctx.env.get('issuer'))
        except ReplicaNotFound, e:
            raise generate_http_error(404, 'ReplicaNotFound', e.args[0][0])
        except RucioException, e:
            raise generate_http_error(500, e.__class__.__name__, e.args[0][0])
        except Exception, e:
            print format_exc()
            raise InternalError(e)
        raise Created()


"""----------------------
   Web service startup
----------------------"""

app = application(urls, globals())
app.add_processor(loadhook(rucio_loadhook))
app.add_processor(unloadhook(rucio_unloadhook))
application = app.wsgifunc()
开发者ID:pombredanne,项目名称:rucio,代码行数:30,代码来源:replica.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.url函数代码示例发布时间:2022-05-26
下一篇:
Python web.unauthorized函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap