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


Python storage.List方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def __init__(self, env):
        Storage.__init__(self)
        self.env = Storage(env)
        self.env.web2py_path = global_settings.applications_parent
        self.env.update(global_settings)
        self.cookies = Cookie.SimpleCookie()
        self._get_vars = None
        self._post_vars = None
        self._vars = None
        self._body = None
        self.folder = None
        self.application = None
        self.function = None
        self.args = List()
        self.extension = 'html'
        self.now = datetime.datetime.now()
        self.utcnow = datetime.datetime.utcnow()
        self.is_restful = False
        self.is_https = False
        self.is_local = False
        self.global_settings = settings.global_settings
        self._uuid = None 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:24,代码来源:globals.py

示例2: test_listcall

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_listcall(self):
        a = List((1, 2, 3))
        self.assertEqual(a(1), 2)
        self.assertEqual(a(-1), 3)
        self.assertEqual(a(-5), None)
        self.assertEqual(a(-5, default='x'), 'x')
        self.assertEqual(a(-3, cast=str), '1')
        a.append('1234')
        self.assertEqual(a(3), '1234')
        self.assertEqual(a(3, cast=int), 1234)
        a.append('x')
        self.assertRaises(HTTP, a, 4, cast=int)
        b = List()
        # default is always returned when especified
        self.assertEqual(b(0, cast=int, default=None), None)
        self.assertEqual(b(0, cast=int, default=None, otherwise='teste'), None)
        self.assertEqual(b(0, cast=int, default='a', otherwise='teste'), 'a')
        # if don't have value and otherwise is especified it will called
        self.assertEqual(b(0, otherwise=lambda: 'something'), 'something')
        self.assertEqual(b(0, cast=int, otherwise=lambda: 'something'),
                         'something')
        # except if default is especified
        self.assertEqual(b(0, default=0, otherwise=lambda: 'something'), 0) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:25,代码来源:test_storage.py

示例3: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def __init__(self, env):
        Storage.__init__(self)
        self.env = Storage(env)
        self.env.web2py_path = global_settings.applications_parent
        self.env.update(global_settings)
        self.cookies = Cookie.SimpleCookie()
        self._get_vars = None
        self._post_vars = None
        self._vars = None
        self._body = None
        self.folder = None
        self.application = None
        self.function = None
        self.args = List()
        self.extension = 'html'
        self.now = datetime.datetime.now()
        self.utcnow = datetime.datetime.utcnow()
        self.is_restful = False
        self.is_https = False
        self.is_local = False
        self.global_settings = settings.global_settings 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:23,代码来源:globals.py

示例4: test_listgetitem

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_listgetitem(self):
        '''Mantains list behaviour.'''
        a = List((1, 2, 3))
        self.assertEqual(a[0], 1)
        self.assertEqual(a[::-1], [3, 2, 1]) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:7,代码来源:test_storage.py

示例5: test_select

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_select(self):
        request = self.env['request']
        request.args = List(['db'])
        request.env.query_string = 'query=db.auth_user.id>0'
        result = self.run_function()
        self.assertTrue('table' in result and 'query' in result)
        self.assertTrue(result['table'] == 'auth_user')
        self.assertTrue(result['query'] == 'db.auth_user.id>0')
        self.env.update(result)
        try:
            self.run_view()
        except Exception as e:
            import traceback
            print(traceback.format_exc())
            self.fail('Could not make the view') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:17,代码来源:test_appadmin.py

示例6: test_insert

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_insert(self):
        request = self.env['request']
        request.args = List(['db', 'auth_user'])
        result = self.run_function()
        self.assertTrue('table' in result)
        self.assertTrue('form' in result)
        self.assertTrue(str(result['table']) is 'auth_user')
        self.env.update(result)
        try:
            self.run_view()
        except Exception as e:
            import traceback
            print(traceback.format_exc())
            self.fail('Could not make the view') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:16,代码来源:test_appadmin.py

示例7: test_update_submit

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_update_submit(self):
        request = self.env['request']
        request.args = List(['db', 'auth_user', '1'])
        form = self.run_function()['form']
        hidden_fields = form.hidden_fields()
        data = {}
        data['_formkey'] = hidden_fields.element('input', _name='_formkey')['_value']
        data['_formname'] = hidden_fields.element('input', _name='_formname')['_value']
        for element in form.elements('input'):
            data[element['_name']] = element['_value']
        data['email'] = '[email protected]'
        data['id'] = '1'
        request._vars = data
        self.assertRaises(HTTP, self.run_function) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:16,代码来源:test_appadmin.py

示例8: parse_path_info

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def parse_path_info(path_info, av=False):
    """
    Parses path info formatted like a/c/f where c and f are optional
    and a leading `/` is accepted.
    Return tuple (a, c, f). If invalid path_info a is set to None.
    If c or f are omitted they are set to None.
    If av=True, parse args and vars
    """
    if av:
        vars = None
        if '?' in path_info:
            path_info, query = path_info.split('?', 2)
            vars = Storage()
            for var in query.split('&'):
                (var, val) = var.split('=', 2) if '=' in var else (var, None)
                vars[var] = val
        items = List(path_info.split('/'))
        args = List(items[3:]) if len(items) > 3 else None
        return (items(0), items(1), items(2), args, vars)

    mo = re.match(r'^/?(?P<a>\w+)(/(?P<c>\w+)(/(?P<f>\w+))?)?$',
                  path_info)
    if mo:
        return (mo.group('a'), mo.group('c'), mo.group('f'))
    else:
        return (None, None, None) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:28,代码来源:shell.py

示例9: map_prefix

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def map_prefix(self):
        """Strips path prefix, if present in its entirety"""
        prefix = routers.BASE.path_prefix
        if prefix:
            prefixlen = len(prefix)
            if prefixlen > len(self.args):
                return
            for i in xrange(prefixlen):
                if prefix[i] != self.args[i]:
                    return  # prefix didn't match
            self.args = List(self.args[prefixlen:])  # strip the prefix 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:13,代码来源:rewrite.py

示例10: test_select

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_select(self):
        request = self.env['request']
        request.args = List(['db'])
        request.env.query_string = 'query=db.auth_user.id>0'
        result = self.run_function()
        self.assertTrue('table' in result and 'query' in result)
        self.assertTrue(result['table'] == 'auth_user')
        self.assertTrue(result['query'] == 'db.auth_user.id>0')
        self.env.update(result)
        try:
            self.run_view()
        except Exception as e:
            print e.message
            self.fail('Could not make the view') 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:16,代码来源:test_appadmin.py

示例11: test_insert

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_insert(self):
        request = self.env['request']
        request.args = List(['db', 'auth_user'])
        result = self.run_function()
        self.assertTrue('table' in result)
        self.assertTrue('form' in result)
        self.assertTrue(str(result['table']) is 'auth_user')
        self.env.update(result)
        try:
            self.run_view()
        except Exception as e:
            print e.message
            self.fail('Could not make the view') 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:15,代码来源:test_appadmin.py

示例12: test_insert_submit

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def test_insert_submit(self):
        request = self.env['request']
        request.args = List(['db', 'auth_user'])
        form = self.run_function()['form']
        hidden_fields = form.hidden_fields()
        data = {}
        data['_formkey'] = hidden_fields.element('input', _name='_formkey')['_value']
        data['_formname'] = hidden_fields.element('input', _name='_formname')['_value']
        data['first_name'] = 'Lisa'
        data['last_name'] = 'Simpson'
        data['username'] = 'lisasimpson'
        data['password'] = 'password_123'
        data['email'] = '[email protected]'
        request._vars = data
        result = self.run_function()
        self.env.update(result)
        try:
            self.run_view()
        except Exception as e:
            print e.message
            self.fail('Could not make the view')
        db = self.env['db']
        lisa_record = db(db.auth_user.username == 'lisasimpson').select().first()
        self.assertIsNotNone(lisa_record)
        del data['_formkey']
        del data['_formname']
        del data['password']
        for key in data:
            self.assertEqual(data[key], lisa_record[key]) 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:31,代码来源:test_appadmin.py

示例13: args

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def args(self):
        return List(self.items[3:]) 
开发者ID:web2py,项目名称:web3py,代码行数:4,代码来源:request.py

示例14: map_prefix

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def map_prefix(self):
        "Strips path prefix, if present in its entirety"
        prefix = routers.BASE.path_prefix
        if prefix:
            prefixlen = len(prefix)
            if prefixlen > len(self.args):
                return
            for i in xrange(prefixlen):
                if prefix[i] != self.args[i]:
                    return  # prefix didn't match
            self.args = List(self.args[prefixlen:])  # strip the prefix 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:13,代码来源:rewrite.py

示例15: __init__

# 需要导入模块: from gluon import storage [as 别名]
# 或者: from gluon.storage import List [as 别名]
def __init__(self, request=None, env=None):
        """Initializes a map-in object"""
        self.request = request
        self.env = env

        self.router = None
        self.application = None
        self.language = None
        self.controller = None
        self.function = None
        self.extension = 'html'

        self.controllers = set()
        self.functions = dict()
        self.languages = set()
        self.default_language = None
        self.map_hyphen = False
        self.exclusive_domain = False

        path = self.env['PATH_INFO']
        self.query = self.env.get('QUERY_STRING', None)
        path = path.lstrip('/')
        self.env['PATH_INFO'] = '/' + path
        self.env['WEB2PY_ORIGINAL_URI'] = self.env['PATH_INFO'] + (
            self.query and ('?' + self.query) or '')

        # to handle empty args, strip exactly one trailing slash, if present
        # .../arg1// represents one trailing empty arg
        #
        if path.endswith('/'):
            path = path[:-1]
        self.args = List(path and path.split('/') or [])

        # see http://www.python.org/dev/peps/pep-3333/#url-reconstruction for URL composition
        self.remote_addr = self.env.get('REMOTE_ADDR', 'localhost')
        self.scheme = self.env.get('wsgi.url_scheme', 'http').lower()
        self.method = self.env.get('REQUEST_METHOD', 'get').lower()
        (self.host, self.port) = (self.env.get('HTTP_HOST'), None)
        if not self.host:
            (self.host, self.port) = (
                self.env.get('SERVER_NAME'), self.env.get('SERVER_PORT'))
        if not self.host:
            (self.host, self.port) = ('localhost', '80')
        if ':' in self.host:
            (self.host, self.port) = self.host.rsplit(':', 1)  # for ipv6 support
        if not self.port:
            self.port = '443' if self.scheme == 'https' else '80' 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:49,代码来源:rewrite.py


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