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


Python Key.from_path方法代码示例

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


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

示例1: post

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
 def post(self):
     query = self.request.get('symptoms')
     id= self.request.get('id')
     did= self.request.get('did')
     dis = self.request.get('disease').split(' ')
     med = self.request.get('medicine')
     		
     sym  = summarize.doctor_symptoms(query)
     q= patient.all(keys_only=True)
     q.filter("__key__ >=", Key.from_path('patient', id))
     res = q.get()
     
     if res:
         d= doctor.all(keys_only=True)
         d.filter("__key__ >=", Key.from_path('doctor', did))
         resd = d.get()
         if resd:
             result ="Updated successfully"
             rec = record(parent=res, symptoms = sym, disease =dis,medicine=med, doc = did)
             rec.rec_date =datetime.datetime.now().date()
             rec.put() 
         else:
             result ="Invalid DocID"
     else:
         result ="Invalid PatientID"
     
     
     
     template_values = {
     'result': result
     
     }
     template = jinja_environment.get_template('message.html')
     self.response.out.write(template.render(template_values))
开发者ID:avontd2868,项目名称:Intelligent_Healthcare_System,代码行数:36,代码来源:main.py

示例2: _map_entity

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def _map_entity(self, entity):
        new_key = Key.from_path(
            self.to_kind, entity.key().id_or_name(), namespace=self.to_namespace
        )

        parent = entity.parent()
        if parent:
            # If the entity has an ancestor then we need to make sure that that ancestor exists in
            # the new namespace as well
            new_parent_key = Key.from_path(
                parent.kind(), parent.is_or_name(), namespace=self.to_namespace
            )
            new_parent_exists = Get([new_parent_key])[0]
            if not new_parent_exists:
                raise DataError(
                    "Trying to copy entity with an ancestor (%r) to a new namespace but the "
                    "ancestor does not exist in the new namespace. Copy the ancestors first."
                    % entity.key()
                )

        def txn():
            existing = Get([new_key])[0]
            if existing and not self.overwrite_existing:
                return
            if isinstance(entity.key().id_or_name(), (int, long)):
                reserve_id(self.to_kind, entity.key().id_or_name(), self.to_namespace)
            new_entity = clone_entity(entity, new_key)
            Put(new_entity)

        RunInTransaction(txn)
开发者ID:andreipetre,项目名称:djangae,代码行数:32,代码来源:operations.py

示例3: create_key

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
def create_key(db_table, value):
    if isinstance(value, GAEKey):
        parent = None
        if value.parent_key() is not None:
            parent = value.parent_key().real_key()
        return Key.from_path(db_table, value.id_or_name(), parent=parent)
    if isinstance(value, (int, long)) and value < 1:
        return None
    return Key.from_path(db_table, value)
开发者ID:aburgel,项目名称:djangoappengine,代码行数:11,代码来源:compiler.py

示例4: put_from_message

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def put_from_message(cls, message):
        """
        Inserts a patient into the DB

        Args:
            message: A PatientPut instance to be inserted.
        Returns:
            The Patient entity that was inserted.
        """
        q = Doctor.all()
        q.filter('__key__ =', Key.from_path('Doctor', message.doctor_email))
        doctor = q.get()

        new_patient = None
        patient = Patient.get_patient(message.email)
        if patient != None:
            new_patient = cls(key_name=message.email,
                        doctor=doctor,
                        first_name=message.first_name,
                        last_name=message.last_name,
                        phone=message.phone,
                        diagnosis=patient.diagnosis,
                        septic_risk=patient.septic_risk,
                        basis_pass=patient.basis_pass)
        else:
            new_patient = cls(key_name=message.email,
                        doctor=doctor,
                        first_name=message.first_name,
                        last_name=message.last_name,
                        phone=message.phone,
                        diagnosis='No',
                        septic_risk=-1.0)
        new_patient.put()
        return new_patient
开发者ID:kpurcell84,项目名称:EECS481-SEED,代码行数:36,代码来源:models.py

示例5: to_python

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def to_python(self, value):
        if value is None:
            return None
        if isinstance(value, GAEKey):
            return value
        if isinstance(value, Key):
            return GAEKey(real_key=value)
        if isinstance(value, basestring):
            try:
                return GAEKey(real_key=Key(encoded=value))
            except datastore_errors.BadKeyError:
                return GAEKey(real_key=Key.from_path(self.model._meta.db_table, long(value)))
        if isinstance(value, (int, long)):
            return GAEKey(real_key=Key.from_path(self.model._meta.db_table, value))

        raise ValidationError("GAEKeyField does not accept %s" % type(value))
开发者ID:aburgel,项目名称:djangoappengine,代码行数:18,代码来源:fields.py

示例6: acquire_marker

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def acquire_marker(identifier):
        # Key.from_path expects None for an empty namespace, but Key.namespace() returns ''
        namespace = entity_key.namespace() or None
        identifier_key = Key.from_path(UniqueMarker.kind(), identifier, namespace=namespace)

        marker = UniqueMarker.get(identifier_key)
        if marker:
            # If the marker instance is None, and the marker is older then 5 seconds then we wipe it out
            # and assume that it's stale.
            if not marker.instance and (datetime.datetime.utcnow() - marker.created).seconds > 5:
                marker.delete()
            elif marker.instance and marker.instance != entity_key and key_exists(marker.instance):
                fields_and_values = identifier.split("|")
                table_name = fields_and_values[0]
                fields_and_values = fields_and_values[1:]
                fields = [ x.split(":")[0] for x in fields_and_values ]
                raise IntegrityError("Unique constraint violation for kind {} on fields: {}".format(table_name, ", ".join(fields)))
            else:
                # The marker is ours anyway
                return marker

        marker = UniqueMarker(
            key=identifier_key,
            instance=entity_key if entity_key.id_or_name() else None,  # May be None if unsaved
            created=datetime.datetime.utcnow()
        )
        marker.put()
        return marker
开发者ID:Willd14469,项目名称:CurrentScaffold,代码行数:30,代码来源:constraints.py

示例7: _fetch_entity

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def _fetch_entity(self, instance):
        kind = instance._meta.db_table
        namespace = connection.settings_dict["NAMESPACE"]

        return Get(
            Key.from_path(kind, instance.pk, namespace=namespace)
        )
开发者ID:grzes,项目名称:djangae,代码行数:9,代码来源:test_jsonfield.py

示例8: get_count

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
def get_count(datastore, counter_id):
  key = Key.from_path('Counter', counter_id, _app=PROJECT_ID)
  entity = yield datastore.get(key)
  if entity is None:
    raise gen.Return(0)

  raise gen.Return(entity.get('count', 0))
开发者ID:AppScale,项目名称:appscale,代码行数:9,代码来源:test_transactions.py

示例9: test_blob

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
 def test_blob(self):
     x = BlobModel(data='lalala')
     x.full_clean()
     x.save()
     e = Get(Key.from_path(BlobModel._meta.db_table, x.pk))
     self.assertEqual(e['data'], x.data)
     x = BlobModel.objects.all()[0]
     self.assertEqual(e['data'], x.data)
开发者ID:sovcn,项目名称:paradigm-old,代码行数:10,代码来源:filter.py

示例10: from_service_id

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
 def from_service_id(cls, service, id):
     '''
     Use this with data returned from get_id().
     '''
     if use_ancestor:
         return cls.objects.get(key=Key.from_path(
             cls._meta.db_table, long(id), parent=service.key
         ))
     return cls.objects.get(service=service, pk=id)
开发者ID:durio,项目名称:multitreehole,代码行数:11,代码来源:models.py

示例11: delete

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def delete(self):
        from rogerthat.models import DSPicklePart, DSPickle

        while True:
            parts = DSPicklePart.all(keys_only=True).ancestor(self.ancestor()).fetch(200)
            if not parts:
                break
            db.delete(parts)
        db.delete(Key.from_path(DSPickle.kind(), self.key))
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:11,代码来源:__init__.py

示例12: get_db_prep_value

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
 def get_db_prep_value(self, value, connection, prepared=False):
     if isinstance(value, AncestorKey):
         # If the key isn't fully initialized pass it through, the InserCompiler will handle it
         if value.key_id is None:
             return value
         return Key.from_path(
             self.model._meta.db_table,
             value.key_id,
             parent=value._parent_key
         )
     return super(GAEKeyField, self).get_db_prep_value(value, connection)
开发者ID:nealedj,项目名称:djangoappengine-1-4,代码行数:13,代码来源:fields.py

示例13: read

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def read(key):
        from rogerthat.models import DSPicklePart, DSPickle

        dsp = db.get(Key.from_path(DSPickle.kind(), key))
        if not dsp:
            return DSPickler(key)
        stream = StringIO()
        for dspp in DSPicklePart.all().ancestor(dsp).filter('version =', dsp.version).order('number'):
            stream.write(str(dspp.data))
        stream.seek(0)
        data = pickle.load(stream)
        return DSPickler(key, dsp.version, data)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:14,代码来源:__init__.py

示例14: get_patient

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
    def get_patient(cls, email):
        """
        Gets patient data

        Args:
            email: Patient e-mail address
        Returns:
            The Patient entity with corresponsing e-mail address
        """
        p = cls.all()
        p.filter('__key__ =', Key.from_path('Patient', email))
        return p.get()
开发者ID:kpurcell84,项目名称:EECS481-SEED,代码行数:14,代码来源:models.py

示例15: mark_deleted_tx

# 需要导入模块: from google.appengine.api.datastore import Key [as 别名]
# 或者: from google.appengine.api.datastore.Key import from_path [as 别名]
        def mark_deleted_tx():
            user = users.get_current_user()
            entry = db.get(Key.from_path(cls.__name__, int(id)))
            if not entry or entry.deleted:
                return  None

            if not user or entry.user_id != user.user_id():
                return None

            entry.modified = now
            entry.deleted = True
            entry.put()
            return entry
开发者ID:jclyne,项目名称:cloudtodolist,代码行数:15,代码来源:todolist_server.py


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