Python google.appengine.ext.db 模块,Text() 实例源码

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

项目:cloud-memory    作者:onejgordon    | 项目源码 | 文件源码
def testTextSanitization(self):
        # Remove non-ascii
        from decimal import Decimal
        volley = [
            ('‘Hello’', 'Hello'),
            (int(10), '10'),
            (False, 'False'),
            (long(20), '20'),
            (u'‘Hello’', 'Hello'),
            (u'‘Hello\nHi’', 'Hello\nHi'),
            (u'Kl\xfcft skr\xe4ms inf\xf6r p\xe5 f\xe9d\xe9ral \xe9lectoral gro\xdfe',
               'Kluft skrams infor pa federal electoral groe'),
            (db.Text(u'‘Hello’'), 'Hello'),
            (db.Text(u'naïve café'), 'naive cafe')
        ]

        for v in volley:
            target = v[1]
            actual = tools.normalize_to_ascii(v[0])
            self.assertEqual(actual, target)
项目:flow-dashboard    作者:onejgordon    | 项目源码 | 文件源码
def testTextSanitization(self):
        # Remove non-ascii
        from decimal import Decimal
        volley = [
            ('‘Hello’', 'Hello'),
            (int(10), '10'),
            (False, 'False'),
            (None, None),
            (long(20), '20'),
            (u'‘Hello’', 'Hello'),
            (u'‘Hello\nHi’', 'Hello\nHi'),
            (u'Kl\xfcft skr\xe4ms inf\xf6r p\xe5 f\xe9d\xe9ral \xe9lectoral gro\xdfe',
             'Kluft skrams infor pa federal electoral groe'),
            (db.Text(u'‘Hello’'), 'Hello'),
            (db.Text(u'naïve café'), 'naive cafe')
        ]

        for v in volley:
            target = v[1]
            actual = tools.normalize_to_ascii(v[0])
            self.assertEqual(actual, target)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def _GetModelTypeForListPropertyType(property_type):
  """Converts (supported) db.ListProperty type to db.Model type."""
  from google.appengine.ext import db
  _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      bool: db.BooleanProperty,
      int: db.IntegerProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY.get(property_type, None)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def _GetModelTypeForEntityType(python_type):
  """Converts python built in type to db.Model type."""

  from google.appengine.ext import db
  _PYTHON_TYPE_TO_MODEL_TYPE = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      int: db.IntegerProperty,
      bool: db.BooleanProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _PYTHON_TYPE_TO_MODEL_TYPE.get(python_type, None)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def _GetModelTypeForListPropertyType(property_type):
  """Converts (supported) db.ListProperty type to db.Model type."""
  from google.appengine.ext import db
  _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      bool: db.BooleanProperty,
      int: db.IntegerProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY.get(property_type, None)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def _GetModelTypeForEntityType(python_type):
  """Converts python built in type to db.Model type."""

  from google.appengine.ext import db
  _PYTHON_TYPE_TO_MODEL_TYPE = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      int: db.IntegerProperty,
      bool: db.BooleanProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _PYTHON_TYPE_TO_MODEL_TYPE.get(python_type, None)
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def __init__(self):
    bulkloader.Loader.__init__(self, 'Category',
                               [('name', unicode),
                                ('slug', unicode),
                                ('description', db.Text),
                                ('is_active', bool)
                               ])
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def get_value_for_datastore(self, model_instance):
        fake_model = getattr(model_instance, self.name)
        if not fake_model:
            return None
        if not self.indexed:
            return db.Text(fake_model.get_value_for_datastore())
        return fake_model.get_value_for_datastore()
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def __init__(self, model, *args, **kwargs):
        self.model = model
        if not kwargs.get('indexed', True):
            self.fake_item_type = db.Text
        super(FakeModelListProperty, self).__init__(
            self.__class__.fake_item_type, *args, **kwargs)
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def get_value_for_datastore(self, model_instance):
        fake_models = getattr(model_instance, self.name)
        if not self.indexed:
            return [db.Text(fake_model.get_value_for_datastore())
                    for fake_model in fake_models]
        return [fake_model.get_value_for_datastore()
                for fake_model in fake_models]
项目:docforever    作者:Udala    | 项目源码 | 文件源码
def get_merkle_chains(self, root_key_name_yesterday):
        k=ndb.Key('DocRoot', root_key_name_yesterday)
        doc_root=k.get()

        if (doc_root.doc_root_hash!=''):
            raise Exception('ERROR! doc_root_hash already used!')

        my_list=DocLine.get_doclines_from_root(root_key_name_yesterday)

        if len(my_list)==0:
            raise Exception('WARNING. No documents to proof.')

        my_list2=map(lambda x:x.content_hash,my_list)

        tree = MerkleTree(my_list2, True)
        tree.build()

        doc_root_hash=binascii.hexlify(tree.root.val)

        for i in range(len(my_list2)):
            merkle_chain=tree.get_chain(i)
            merkle_chain2=map(lambda x: (binascii.hexlify(x[0]),x[1]), merkle_chain)

            my_list[i].merkle_chain=db.Text(str(merkle_chain2), encoding="latin-1")
            my_list[i].doc_root=doc_root_hash
            my_list[i].put()

        doc_root=k.get()

        doc_root.doc_root_hash=doc_root_hash
        doc_root.date_broadcast=test.utcnow()
        doc_root.nodes=db.Text(str(map(lambda x: binascii.hexlify(x.val), tree.leaves)), encoding='latin-1')
        doc_root.put()
        return doc_root_hash
项目:docforever    作者:Udala    | 项目源码 | 文件源码
def new(cls, parent, content_hash, date_received):
        d = cls(parent=parent, content_hash=content_hash, date_received=date_received, doc_root='', merkle_chain=db.Text('', encoding="utf-8"))
        d.put()
        return d
项目:docforever    作者:Udala    | 项目源码 | 文件源码
def new(cls, key_name):
        # http://stackoverflow.com/questions/24332648/google-app-engine-no-key-name-attribute
        d=cls(id=key_name, doc_root_hash='', date_broadcast=None, nodes=db.Text('', encoding='utf-8'), txid='')
        d.put()
        return d
项目:docforever    作者:Udala    | 项目源码 | 文件源码
def new(cls, message):        
        d = cls(message=db.Text(message) if isinstance(message,unicode) else db.Text(message, encoding='utf-8'),
                date_received=test.utcnow())
        d.put()
        return d
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def _GetModelTypeForListPropertyType(property_type):
  """Converts (supported) db.ListProperty type to db.Model type."""
  from google.appengine.ext import db
  _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      bool: db.BooleanProperty,
      int: db.IntegerProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY.get(property_type, None)
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def _GetModelTypeForEntityType(python_type):
  """Converts python built in type to db.Model type."""

  from google.appengine.ext import db
  _PYTHON_TYPE_TO_MODEL_TYPE = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      int: db.IntegerProperty,
      bool: db.BooleanProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _PYTHON_TYPE_TO_MODEL_TYPE.get(python_type, None)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def _GetModelTypeForListPropertyType(property_type):
  """Converts (supported) db.ListProperty type to db.Model type."""
  from google.appengine.ext import db
  _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      bool: db.BooleanProperty,
      int: db.IntegerProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY.get(property_type, None)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def _GetModelTypeForEntityType(python_type):
  """Converts python built in type to db.Model type."""

  from google.appengine.ext import db
  _PYTHON_TYPE_TO_MODEL_TYPE = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      int: db.IntegerProperty,
      bool: db.BooleanProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _PYTHON_TYPE_TO_MODEL_TYPE.get(python_type, None)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def _GetModelTypeForListPropertyType(property_type):
  """Converts (supported) db.ListProperty type to db.Model type."""
  from google.appengine.ext import db
  _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      bool: db.BooleanProperty,
      int: db.IntegerProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _LISTPROPERTY_TYPE_TO_SCHEMA_ENTRY.get(property_type, None)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def _GetModelTypeForEntityType(python_type):
  """Converts python built in type to db.Model type."""

  from google.appengine.ext import db
  _PYTHON_TYPE_TO_MODEL_TYPE = {
      basestring: db.StringProperty,
      str: db.StringProperty,
      unicode: db.StringProperty,
      int: db.IntegerProperty,
      bool: db.BooleanProperty,
      float: db.FloatProperty,
      db.Text: db.TextProperty,
  }
  return _PYTHON_TYPE_TO_MODEL_TYPE.get(python_type, None)