Python google.appengine.ext.ndb 模块,StringProperty() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用google.appengine.ext.ndb.StringProperty()

项目:appbackendapi    作者:codesdk    | 项目源码 | 文件源码
def query_purchase_with_customer_key():
    # [START purchase_with_customer_key_models]
    class Customer(ndb.Model):
        name = ndb.StringProperty()

    class Purchase(ndb.Model):
        customer = ndb.KeyProperty(kind=Customer)
        price = ndb.IntegerProperty()
    # [END purchase_with_customer_key_models]

    def query_purchases_for_customer_via_key(customer_entity):
        purchases = Purchase.query(
            Purchase.customer == customer_entity.key).fetch()
        return purchases

    return Customer, Purchase, query_purchases_for_customer_via_key
项目:appbackendapi    作者:codesdk    | 项目源码 | 文件源码
def query_purchase_with_ancestor_key():
    # [START purchase_with_ancestor_key_models]
    class Customer(ndb.Model):
        name = ndb.StringProperty()

    class Purchase(ndb.Model):
        price = ndb.IntegerProperty()
    # [END purchase_with_ancestor_key_models]

    def create_purchase_for_customer_with_ancestor(customer_entity):
        purchase = Purchase(parent=customer_entity.key)
        return purchase

    def query_for_purchases_of_customer_with_ancestor(customer_entity):
        purchases = Purchase.query(ancestor=customer_entity.key).fetch()
        return purchases

    return (Customer, Purchase,
            create_purchase_for_customer_with_ancestor,
            query_for_purchases_of_customer_with_ancestor)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:start    作者:argeweb    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.StringField(**kwargs)
项目:start    作者:argeweb    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        if prop._required:
            kwargs['validators'].append(validators.InputRequired())
        # kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testNoneResult_raisesException(self, patch_convert):
        from graphene_gae.ndb.converter import convert_ndb_property
        patch_convert.get.return_value = lambda *_: None
        with self.assertRaises(Exception) as context:
            prop = ndb.StringProperty()
            prop._code_name = "my_prop"
            convert_ndb_property(prop)

        expected_message = 'Failed to convert NDB propeerty to a GraphQL field my_prop (StringProperty())'
        self.assertTrue(expected_message in context.exception.message, msg=context.exception.message)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testStringProperty_shouldConvertToString(self):
        self.__assert_conversion(ndb.StringProperty, graphene.String)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testStringProperty_repeated_shouldConvertToList(self):
        ndb_prop = ndb.StringProperty(repeated=True)
        result = convert_ndb_property(ndb_prop)
        graphene_type = result.field._type

        self.assertIsInstance(graphene_type, graphene.List)
        self.assertEqual(graphene_type.of_type, graphene.String)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testStringProperty_required_shouldConvertToList(self):
        ndb_prop = ndb.StringProperty(required=True)
        result = convert_ndb_property(ndb_prop)
        graphene_type = result.field._type

        self.assertIsInstance(graphene_type, graphene.NonNull)
        self.assertEqual(graphene_type.of_type, graphene.String)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testKeyProperty_withSuffix(self):
        my_registry = Registry()

        class User(ndb.Model):
            name = ndb.StringProperty()

        class UserType(NdbObjectType):
            class Meta:
                model = User
                registry = my_registry

        prop = ndb.KeyProperty(kind='User')
        prop._code_name = 'user_key'

        conversion = convert_ndb_property(prop, my_registry)

        self.assertLength(conversion, 2)

        self.assertEqual(conversion[0].name, 'user_id')
        self.assertIsInstance(conversion[0].field, DynamicNdbKeyStringField)
        _type = conversion[0].field.get_type()
        self.assertIsInstance(_type, NdbKeyStringField)
        self.assertEqual(_type._type, String)

        self.assertEqual(conversion[1].name, 'user')
        self.assertIsInstance(conversion[1].field, DynamicNdbKeyReferenceField)
        _type = conversion[1].field.get_type()
        self.assertIsInstance(_type, NdbKeyReferenceField)
        self.assertEqual(_type._type, UserType)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testKeyProperty_withSuffix_required(self):
        class User(ndb.Model):
            name = ndb.StringProperty()

        my_registry = Registry()

        class UserType(NdbObjectType):
            class Meta:
                model = User
                registry = my_registry

        prop = ndb.KeyProperty(kind='User', required=True)
        prop._code_name = 'user_key'

        conversion = convert_ndb_property(prop, my_registry)

        self.assertLength(conversion, 2)

        self.assertEqual(conversion[0].name, 'user_id')
        self.assertIsInstance(conversion[0].field, DynamicNdbKeyStringField)
        _type = conversion[0].field.get_type()
        self.assertIsInstance(_type, NdbKeyStringField)
        self.assertIsInstance(_type._type, NonNull)
        self.assertEqual(_type._type.of_type, String)

        self.assertEqual(conversion[1].name, 'user')
        self.assertIsInstance(conversion[1].field, DynamicNdbKeyReferenceField)
        _type = conversion[1].field.get_type()
        self.assertIsInstance(_type, NdbKeyReferenceField)
        self.assertIsInstance(_type._type, NonNull)
        self.assertEqual(_type._type.of_type, UserType)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testKeyProperty_withoutSuffix(self):
        my_registry = Registry()

        class User(ndb.Model):
            name = ndb.StringProperty()

        class UserType(NdbObjectType):
            class Meta:
                model = User
                registry = my_registry

        prop = ndb.KeyProperty(kind='User')
        prop._code_name = 'user'

        conversion = convert_ndb_property(prop, my_registry)

        self.assertLength(conversion, 2)

        self.assertEqual(conversion[0].name, 'user_id')
        self.assertIsInstance(conversion[0].field, DynamicNdbKeyStringField)
        _type = conversion[0].field.get_type()
        self.assertIsInstance(_type, NdbKeyStringField)
        self.assertEqual(_type._type, String)

        self.assertEqual(conversion[1].name, 'user')
        self.assertIsInstance(conversion[1].field, DynamicNdbKeyReferenceField)
        _type = conversion[1].field.get_type()
        self.assertIsInstance(_type, NdbKeyReferenceField)
        self.assertEqual(_type._type, UserType)
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def convert_StringProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.StringProperty``."""
        if prop._repeated:
            return StringListPropertyField(**kwargs)
        kwargs['validators'].append(validators.length(max=500))
        return get_TextField(kwargs)
项目:raw-data-repository    作者:all-of-us    | 项目源码 | 文件源码
def __init__(self, model_type, ancestor_type=None, keep_history=True):
    self.model_type = model_type
    self.ancestor_type = ancestor_type
    self.model_name = model_type.__name__
    self.keep_history = keep_history

    if self.keep_history:
      history_props = {
          'date': ndb.DateTimeProperty(auto_now_add=True),
          'obj': ndb.StructuredProperty(model_type, repeated=False),
          'client_id': ndb.StringProperty(),
      }
      self.history_model = type(
          self.model_name + 'History', (ndb.Model,), history_props)
项目:Hawkeye    作者:tozhengxq    | 项目源码 | 文件源码
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``ndb.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)