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


Python serializers.json方法代码示例

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


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

示例1: CONTAINS

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def CONTAINS(self,first,second,case_sensitive=False):
        if first.type in ('string','text', 'json'):
            if isinstance(second,Expression):
                second = Expression(None,self.CONCAT('%',Expression(
                            None,self.REPLACE(second,('%','%%'))),'%'))
            else:
                second = '%'+str(second).replace('%','%%')+'%'
        elif first.type.startswith('list:'):
            if isinstance(second,Expression):
                second = Expression(None,self.CONCAT(
                        '%|',Expression(None,self.REPLACE(
                                Expression(None,self.REPLACE(
                                        second,('%','%%'))),('|','||'))),'|%'))
            else:
                second = '%|'+str(second).replace('%','%%')\
                    .replace('|','||')+'|%'
        op = case_sensitive and self.LIKE or self.ILIKE
        return op(first,second) 
开发者ID:whbrewer,项目名称:spc,代码行数:20,代码来源:dal.py

示例2: build_parsemap

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def build_parsemap(self):
        self.parsemap = {
            'id':self.parse_id,
            'integer':self.parse_integer,
            'bigint':self.parse_integer,
            'float':self.parse_double,
            'double':self.parse_double,
            'reference':self.parse_reference,
            'boolean':self.parse_boolean,
            'date':self.parse_date,
            'time':self.parse_time,
            'datetime':self.parse_datetime,
            'blob':self.parse_blob,
            'decimal':self.parse_decimal,
            'json':self.parse_json,
            'list:integer':self.parse_list_integers,
            'list:reference':self.parse_list_references,
            'list:string':self.parse_list_strings,
            } 
开发者ID:whbrewer,项目名称:spc,代码行数:21,代码来源:dal.py

示例3: as_json

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def as_json(self, mode='object', default=None):
        """
        serializes the rows to a JSON list or object with objects
        mode='object' is not implemented (should return a nested
        object structure)
        """

        items = [record.as_json(mode=mode, default=default,
                                serialize=False,
                                colnames=self.colnames) for
                 record in self]

        if have_serializers:
            return serializers.json(items,
                                    default=default or
                                    serializers.custom_json)
        elif simplejson:
            return simplejson.dumps(items)
        else:
            raise RuntimeError("missing simplejson")

    # for consistent naming yet backwards compatible 
开发者ID:whbrewer,项目名称:spc,代码行数:24,代码来源:dal.py

示例4: ASSIGNJS

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def ASSIGNJS(**kargs):
    """
    Example:
        ASSIGNJS(var1='1', var2='2') will return the following javascript variables assignations :

            var var1 = "1";
            var var2 = "2";

    Args:
        **kargs: Any keywords arguments and assigned values.

    Returns:
        Javascript vars assignations for the key/value passed.

    """
    from gluon.serializers import json
    s = ""
    for key, value in kargs.items():
        s += 'var %s = %s;\n' % (key, json(value))
    return XML(s) 
开发者ID:TechMaz,项目名称:Problematica-public,代码行数:22,代码来源:html.py

示例5: as_json

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def as_json(self, sanitize=True):
        d = self.as_dict(flat=True, sanitize=sanitize)
        from serializers import json
        return json(d) 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:6,代码来源:html.py

示例6: ASSIGNJS

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def ASSIGNJS(**kargs):
    from gluon.serializers import json
    s = ""
    for key, value in kargs.items():
        s+='var %s = %s;\n' % (key, json(value))
    return XML(s) 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:8,代码来源:html.py

示例7: widget

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def widget(cls, field, value, **attributes):
        """
        generates a TEXTAREA for JSON notation.

        see also: :meth:`FormWidget.widget`
        """
        if not isinstance(value, basestring):
            if value is not None:
                value = serializers.json(value)
        default = dict(value=value)
        attr = cls._attributes(field, default, **attributes)
        return TEXTAREA(**attr) 
开发者ID:whbrewer,项目名称:spc,代码行数:14,代码来源:sqlhtml.py

示例8: expand

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def expand(self, expression, field_type=None):
        if isinstance(expression, Field):
            out = '%s.%s' % (expression.table._tablename, expression.name)
            if field_type == 'string' and not expression.type in (
                'string','text','json','password'):
                out = 'CAST(%s AS %s)' % (out, self.types['text'])
            return out
        elif isinstance(expression, (Expression, Query)):
            first = expression.first
            second = expression.second
            op = expression.op
            optional_args = expression.optional_args or {}
            if not second is None:
                out = op(first, second, **optional_args)
            elif not first is None:
                out = op(first,**optional_args)
            elif isinstance(op, str):
                if op.endswith(';'):
                    op=op[:-1]
                out = '(%s)' % op
            else:
                out = op()
            return out
        elif field_type:
            return str(self.represent(expression,field_type))
        elif isinstance(expression,(list,tuple)):
            return ','.join(self.represent(item,field_type) \
                                for item in expression)
        elif isinstance(expression, bool):
            return '1' if expression else '0'
        else:
            return str(expression) 
开发者ID:whbrewer,项目名称:spc,代码行数:34,代码来源:dal.py

示例9: parse_json

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def parse_json(self, value, field_type):
        if not self.native_json:
            if not isinstance(value, basestring):
                raise RuntimeError('json data not a string')
            if isinstance(value, unicode):
                value = value.encode('utf-8')
            if have_serializers:
                value = serializers.loads_json(value)
            elif simplejson:
                value = simplejson.loads(value)
            else:
                raise RuntimeError("missing simplejson")
        return value 
开发者ID:whbrewer,项目名称:spc,代码行数:15,代码来源:dal.py

示例10: try_json

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def try_json(self):
        # check JSON data type support
        # (to be added to after_connection)
        if self.driver_name == "pg8000":
            supports_json = self.connection.server_version >= "9.2.0"
        elif (self.driver_name == "psycopg2") and \
             (self.driver.__version__ >= "2.0.12"):
            supports_json = self.connection.server_version >= 90200
        elif self.driver_name == "zxJDBC":
            supports_json = self.connection.dbversion >= "9.2.0"
        else: supports_json = None
        if supports_json:
            self.types["json"] = "JSON"
            self.native_json = True
        else: LOGGER.debug("Your database version does not support the JSON data type (using TEXT instead)") 
开发者ID:whbrewer,项目名称:spc,代码行数:17,代码来源:dal.py

示例11: LIKE

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def LIKE(self,first,second):
        args = (self.expand(first), self.expand(second,'string'))
        if not first.type in ('string', 'text', 'json'):
            return '(CAST(%s AS CHAR(%s)) LIKE %s)' % (args[0], first.length, args[1])
        else:
            return '(%s LIKE %s)' % args 
开发者ID:whbrewer,项目名称:spc,代码行数:8,代码来源:dal.py

示例12: ILIKE

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def ILIKE(self,first,second):
        args = (self.expand(first), self.expand(second,'string'))
        if not first.type in ('string', 'text', 'json'):
            return '(CAST(%s AS CHAR(%s)) LIKE %s)' % (args[0], first.length, args[1])
        else:
            return '(%s ILIKE %s)' % args 
开发者ID:whbrewer,项目名称:spc,代码行数:8,代码来源:dal.py

示例13: represent

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def represent(self, obj, fieldtype):
        value = BaseAdapter.represent(self, obj, fieldtype)
        if fieldtype in ('string','text', 'json') and value[:1]=="'":
            value = 'N'+value
        return value 
开发者ID:whbrewer,项目名称:spc,代码行数:7,代码来源:dal.py

示例14: __init__

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def __init__(self,db,uri,pool_size=0,folder=None,db_codec ='UTF-8',
                 credential_decoder=IDENTITY, driver_args={},
                 adapter_args={}, do_connect=True, after_connection=None):
        self.types.update({
                'boolean': gae.BooleanProperty,
                'string': (lambda **kwargs: gae.StringProperty(multiline=True, **kwargs)),
                'text': gae.TextProperty,
                'json': gae.TextProperty,
                'password': gae.StringProperty,
                'blob': gae.BlobProperty,
                'upload': gae.StringProperty,
                'integer': gae.IntegerProperty,
                'bigint': gae.IntegerProperty,
                'float': gae.FloatProperty,
                'double': gae.FloatProperty,
                'decimal': GAEDecimalProperty,
                'date': gae.DateProperty,
                'time': gae.TimeProperty,
                'datetime': gae.DateTimeProperty,
                'id': None,
                'reference': gae.IntegerProperty,
                'list:string': (lambda **kwargs: gae.StringListProperty(default=None, **kwargs)),
                'list:integer': (lambda **kwargs: gae.ListProperty(int,default=None, **kwargs)),
                'list:reference': (lambda **kwargs: gae.ListProperty(int,default=None, **kwargs)),
                })
        self.db = db
        self.uri = uri
        self.dbengine = 'google:datastore'
        self.folder = folder
        db['_lastsql'] = ''
        self.db_codec = 'UTF-8'
        self._after_connection = after_connection
        self.pool_size = 0
        match = self.REGEX_NAMESPACE.match(uri)
        if match:
            namespace_manager.set_namespace(match.group('namespace')) 
开发者ID:whbrewer,项目名称:spc,代码行数:38,代码来源:dal.py

示例15: startswith

# 需要导入模块: import serializers [as 别名]
# 或者: from serializers import json [as 别名]
def startswith(self, value):
        db = self.db
        if not self.type in ('string', 'text', 'json'):
            raise SyntaxError("startswith used with incompatible field type")
        return Query(db, db._adapter.STARTSWITH, self, value) 
开发者ID:whbrewer,项目名称:spc,代码行数:7,代码来源:dal.py


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