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


Python storage.Storage方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def __init__(self, db, download_url=('default','download')):
        """
        Initializes the CKEditor module. Requires a DAL instance.
        """

        self.db = db

        self.settings = Storage()
        self.settings.table_upload = None
        self.settings.uploadfs = None
        self.settings.table_upload_name = 'plugin_ckeditor_upload'
        self.settings.extra_fields = {}
        self.settings.url_upload = URL('plugin_ckeditor', 'upload')
        self.settings.url_browse = URL('plugin_ckeditor', 'browse')
        self.settings.browse_filter = {}
        self.settings.file_length_max = 10485760    # 10 MB
        self.settings.file_length_min = 0           # no minimum
        self.settings.spellcheck_while_typing = False

        self.settings.download_url = download_url
        current.plugin_ckeditor = self 
开发者ID:ybenitezf,项目名称:nstock,代码行数:23,代码来源:plugin_ckeditor.py

示例2: insert

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def insert(self, **kwargs):
        # usually kwargs would be a Storage with several keys:
        # 'locked', 'client_ip','created_datetime','modified_datetime'
        # 'unique_key', 'session_data'
        # retrieve a new key
        newid = str(self.db.r_server.incr(self.serial))
        key = self.keyprefix + ':' + newid
        if self.with_lock:
            key_lock = key + ':lock'
            acquire_lock(self.db.r_server, key_lock, newid)
        with self.db.r_server.pipeline() as pipe:
            # add it to the index
            pipe.sadd(self.id_idx, key)
            # set a hash key with the Storage
            pipe.hmset(key, kwargs)
            if self.session_expiry:
                pipe.expire(key, self.session_expiry)
            pipe.execute()
        if self.with_lock:
            release_lock(self.db, key_lock, newid)
        return newid 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:23,代码来源:redis_session.py

示例3: get_user

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def get_user(self):
        request = self.request
        if request.vars.token:
            user = Storage()
            data = urllib.urlencode(
                dict(apiKey=self.api_key, token=request.vars.token))
            auth_info_json = fetch(self.auth_url + '?' + data)
            auth_info = json.loads(auth_info_json)

            if auth_info['stat'] == 'ok':
                self.profile = auth_info['profile']
                provider = re.sub('[^\w\-]', '', self.profile['providerName'])
                user = self.mappings.get(
                    provider, self.mappings.default)(self.profile)
                return user
            elif self.on_login_failure:
                redirect(self.on_login_failure)
        return None 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:20,代码来源:rpx_account.py

示例4: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def __init__(self, request, api_key="", api_secret="",
                 url="", on_login_failure=None):

        self.request = request
        self.api_key = api_key
        self.api_secret = api_secret
        self.url = url
        self.auth_base_url = "https://hub.loginradius.com/UserProfile.ashx/"
        self.profile = None
        self.on_login_failure = on_login_failure
        self.mappings = Storage()

        def defaultmapping(profile):
            first_name = profile.get('FirstName')
            last_name = profile.get('LastName')
            email = profile.get('Email', [{}])[0].get('Value')
            reg_id = profile.get('ID', '')
            username = profile.get('ProfileName', email)

            return dict(registration_id=reg_id, username=username, email=email,
                        first_name=first_name, last_name=last_name)

        self.mappings.default = defaultmapping 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:25,代码来源:loginradius_account.py

示例5: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def __init__(self, request, public_key="", private_key="",  domain="",
                       url=None, providers=None, on_login_failure=None):

        self.request = request
        self.public_key = public_key
        self.private_key = private_key
        self.url = url
        self.domain = domain
        self.profile = None
        self.on_login_failure = on_login_failure
        self.providers = providers or ["facebook", "google", "yahoo", "openid"]

        self.mappings = Storage()
        def defaultmapping(profile):
            name = profile.get('name',{})
            dname = name.get('formatted',profile.get('displayName'))
            email=profile.get('emails', [{}])[0].get('value')
            reg_id=profile.get('identity_token','')
            username=profile.get('preferredUsername',email)
            first_name=name.get('givenName', dname.split(' ')[0])
            last_name=profile.get('familyName', dname.split(' ')[1] if(dname.count(' ') > 0) else None)
            return dict(registration_id=reg_id,username=username,email=email,
                        first_name=first_name,last_name=last_name)
        self.mappings.default = defaultmapping 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:26,代码来源:oneall_account.py

示例6: get_user

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def get_user(self):
        request = self.request
        if request.vars.token:
            user = Storage()
            data = urllib.urlencode(dict(token=request.vars.token))
            auth_info_json = fetch(self.auth_url + '?' + data)
            # print auth_info_json
            auth_info = json.loads(auth_info_json)
            if auth_info["identity"] is not None:
                self.profile = auth_info
                provider = self.profile["provider"]
                user = self.mappings.get(
                    provider, self.mappings.default)(self.profile)
                # user["password"] = ???
                # user["avatar"] = ???
                return user
            elif self.on_login_failure:
                redirect(self.on_login_failure)
        return None 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:21,代码来源:loginza.py

示例7: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def __init__(self,
                 request=None,
                 public_key='',
                 private_key='',
                 error_message='invalid',
                 label='Verify:',
                 options=None,
                 comment='',
                 ):
        request = request or current.request
        self.request_vars = request and request.vars or current.request.vars
        self.remote_addr = request.env.remote_addr
        self.public_key = public_key
        self.private_key = private_key
        self.errors = Storage()
        self.error_message = error_message
        self.components = []
        self.attributes = {}
        self.label = label
        self.options = options or {}
        self.comment = comment 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:23,代码来源:tools.py

示例8: test_appconfig

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def test_appconfig(self):
        """
        Test for the appconfig module
        """
        from gluon import current
        s = Storage({'application': 'admin',
                     'folder': 'applications/admin'})
        current.request = s
        simple_config = '{"config1" : "abc", "config2" : "bcd", "config3" : { "key1" : 1, "key2" : 2} }'
        with open('appconfig.json', 'w') as g:
            g.write(simple_config)
        myappconfig = AppConfig('appconfig.json')
        self.assertEqual(myappconfig['config1'], 'abc')
        self.assertEqual(myappconfig['config2'], 'bcd')
        self.assertEqual(myappconfig.take('config1'), 'abc')
        self.assertEqual(myappconfig.take('config3.key1', cast=str), '1')
        # once parsed, can't be casted to other types
        self.assertEqual(myappconfig.take('config3.key1', cast=int), '1')

        self.assertEqual(myappconfig.take('config3.key2'), 2)

        current.request = {} 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:test_contribs.py

示例9: get_workers

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def get_workers(self, only_ticker=False):
        """ Returns a dict holding `worker_name : {**columns}`
        representing all "registered" workers
        only_ticker returns only the workers running as a TICKER,
        if there are any
        """
        db = self.db
        if only_ticker:
            workers = db(db.scheduler_worker.is_ticker == True).select()
        else:
            workers = db(db.scheduler_worker.id > 0).select()
        all_workers = {}
        for row in workers:
            all_workers[row.worker_name] = Storage(
                status=row.status,
                first_heartbeat=row.first_heartbeat,
                last_heartbeat=row.last_heartbeat,
                group_names=row.group_names,
                is_ticker=row.is_ticker,
                worker_stats=row.worker_stats
            )
        return all_workers 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:scheduler.py

示例10: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def __init__(self, request, public_key="", private_key="",  domain="",
                       url=None, providers=None, on_login_failure=None):

        self.request = request
        self.public_key = public_key
        self.private_key = private_key
        self.url = url
        self.domain = domain
        self.profile = None
        self.on_login_failure = on_login_failure
        self.providers = providers or ["facebook", "google", "yahoo", "openid"]

        self.mappings = Storage()
        def defaultmapping(profile):
            name = profile.get('name',{})
            dname = name.get('formatted',profile.get('displayName'))
            email=profile.get('emails', [{}])[0].get('value')
            reg_id=profile.get('identity_token','')
            username=profile.get('preferredUsername',email)
            first_name=name.get('givenName', dname.split(' ')[0])
            last_name=profile.get('familyName',dname.split(' ')[1])
            return dict(registration_id=reg_id,username=username,email=email,
                        first_name=first_name,last_name=last_name)
        self.mappings.default = defaultmapping 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:26,代码来源:oneall_account.py

示例11: get_user

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def get_user(self):
        request = self.request
        if request.vars.token:
            user = Storage()
            data = urllib.urlencode(dict(token=request.vars.token))
            auth_info_json = fetch(self.auth_url + '?' + data)
            #print auth_info_json
            auth_info = json.loads(auth_info_json)
            if auth_info["identity"] is not None:
                self.profile = auth_info
                provider = self.profile["provider"]
                user = self.mappings.get(
                    provider, self.mappings.default)(self.profile)
                #user["password"] = ???
                #user["avatar"] = ???
                return user
            elif self.on_login_failure:
                redirect(self.on_login_failure)
        return None 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:21,代码来源:loginza.py

示例12: login_user

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        from gluon.settings import global_settings
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, 'password')
        else:
            user = Row(user)
            for key, value in user.items():
                if callable(value) or key == 'password':
                    delattr(user, key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:23,代码来源:tools.py

示例13: _params_default

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def _params_default(app=None):
    """Returns a new copy of default parameters"""
    p = Storage()
    p.name = app or "BASE"
    p.default_application = app or "init"
    p.default_controller = "default"
    p.default_function = "index"
    p.routes_app = []
    p.routes_in = []
    p.routes_out = []
    p.routes_onerror = []
    p.routes_apps_raw = []
    p.error_handler = None
    p.error_message = '<html><body><h1>%s</h1></body></html>'
    p.error_message_ticket = \
        '<html><body><h1>Internal error</h1>Ticket issued: <a href="/admin/default/ticket/%(ticket)s" target="_blank">%(ticket)s</a></body><!-- this is junk text else IE does not display the page: ' + ('x' * 512) + ' //--></html>'
    p.routers = None
    p.logging = 'off'
    return p 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:21,代码来源:rewrite.py

示例14: insert

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def insert(self, **kwargs):
        #usually kwargs would be a Storage with several keys:
        #'locked', 'client_ip','created_datetime','modified_datetime'
        #'unique_key', 'session_data'
        #retrieve a new key
        newid = str(self.r_server.incr(self.serial))
        key = self.keyprefix + ':' + newid
        if self.with_lock:
            key_lock = key + ':lock'
            acquire_lock(self.r_server, key_lock, newid)
        with self.r_server.pipeline() as pipe:
            #add it to the index
            pipe.sadd(self.id_idx, key)
            #set a hash key with the Storage
            pipe.hmset(key, kwargs)
            if self.session_expiry:
                pipe.expire(key, self.session_expiry)
            pipe.execute()
        if self.with_lock:
            release_lock(self.r_server, key_lock, newid)
        return newid 
开发者ID:whbrewer,项目名称:spc,代码行数:23,代码来源:redis_session.py

示例15: login_user

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import Storage [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        from gluon.settings import global_settings
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, 'password')
        else:
            user = Row(user)
            for key in list(user.keys()):
                value = user[key]
                if callable(value) or key == 'password':
                    delattr(user, key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:rekall-innovations,项目名称:rekall-agent-server,代码行数:24,代码来源:tools.py


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