當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。