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


Python gluon.current方法代码示例

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


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

示例1: __call__

# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import current [as 别名]
def __call__(self):
        from gluon import current
        user_agent = current.request.user_agent()
        if user_agent.is_mobile:
            items = current.response.view.split('.')
            items.insert(-1, 'mobile')
            current.response.view = '.'.join(items)
        return self.func() 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:10,代码来源:user_agent_parser.py

示例2: __init__

# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import current [as 别名]
def __init__(self, db, tasks=None, migrate=True,
                 worker_name=None, group_names=None, heartbeat=HEARTBEAT,
                 max_empty_runs=0, discard_results=False, utc_time=False,
                 redis_conn=None, mode=1):

        """
        Highly-experimental coordination with redis
        Takes all args from Scheduler except redis_conn which
        must be something closer to a StrictRedis instance.

        My only regret - and the reason why I kept this under the hood for a
        while - is that it's hard to hook up in web2py to something happening
        right after the commit to a table, which will enable this version of the
        scheduler to process "immediate" tasks right away instead of waiting a
        few seconds (see FIXME in queue_task())

        mode is reserved for future usage patterns.
        Right now it moves the coordination (which is the most intensive
        routine in the scheduler in matters of IPC) of workers to redis.
        I'd like to have incrementally redis-backed modes of operations,
        such as e.g.:
            - 1: IPC through redis (which is the current implementation)
            - 2: Store task results in redis (which will relieve further pressure
                 from the db leaving the scheduler_run table empty and possibly
                 keep things smooth as tasks results can be set to expire
                 after a bit of time)
            - 3: Move all the logic for storing and queueing tasks to redis
                 itself - which means no scheduler_task usage too - and use
                 the database only as an historical record-bookkeeping
                 (e.g. for reporting)

        As usual, I'm eager to see your comments.
        """

        Scheduler.__init__(self, db, tasks=tasks, migrate=migrate,
                           worker_name=worker_name, group_names=group_names,
                           heartbeat=heartbeat, max_empty_runs=max_empty_runs,
                           discard_results=discard_results, utc_time=utc_time)

        self.r_server = redis_conn
        from gluon import current
        self._application = current.request.application or 'appname' 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:44,代码来源:redis_scheduler.py


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