def __init__(self, app_id): apiproxy_stub.APIProxyStub.__init__(self, SERVICE_NAME) self.__app_id = app_id self.__entity_converter = datastore_pbs.get_entity_converter() self.__service_converter = datastore_stub_util.get_service_converter() self.__service_validator = datastore_v4_validator.get_service_validator( )
def __init__(self, app_id): assert _CLOUD_DATASTORE_ENABLED, ( "Cannot initialize the Cloud Datastore" " stub without installing the Cloud" " Datastore client libraries." ) apiproxy_stub.APIProxyStub.__init__(self, SERVICE_NAME) self.__app_id = app_id self._id_resolver = _StubIdResolver([app_id]) self.__entity_converter = datastore_pbs.get_entity_converter(self._id_resolver) self.__service_converter = datastore_stub_util.get_service_converter(self._id_resolver) self.__service_validator = cloud_datastore_validator.get_service_validator(self._id_resolver)
def __init__(self, app_id): assert _CLOUD_DATASTORE_ENABLED, ( 'Cannot initialize the Cloud Datastore' ' stub without installing the Cloud' ' Datastore client libraries.') apiproxy_stub.APIProxyStub.__init__(self, SERVICE_NAME) self.__app_id = app_id id_resolver = _StubIdResolver([app_id]) self.__entity_converter = datastore_pbs.get_entity_converter( id_resolver) self.__service_converter = datastore_stub_util.get_service_converter( id_resolver) self.__service_validator = cloud_datastore_validator.get_service_validator( )
def run(): # Set your downloaded folder's path here (must be readable by dev_appserver) mypath = '/local_target' # Set your app's name here appname = "dev~yourappnamehere" # Do the harlem shake onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] ec = datastore_pbs.get_entity_converter() for file in onlyfiles: i = 0 try: raw = open(mypath + "/" + file, 'r') reader = records.RecordsReader(raw) to_put = list() for record in reader: entity_proto = entity_pb.EntityProto(contents=record) entity_proto.key_.app_ = appname entity = db.model_from_protobuf(entity_proto) a = db.model_from_protobuf(entity_proto) for pp in dir(a): try: ppp = getattr(a, "_" + pp) if isinstance(ppp, db.Key): ppp._Key__reference.set_app(appname) ppp except AttributeError: """ It's okay """ to_put.append(a) i += 1 if i % 100 == 0: print "Saved %d %ss" % (i, entity.kind()) db.put(to_put) to_put = list() db.put(to_put) to_put = list() print "Saved %d" % i except ProtocolBufferDecodeError: """ All good """
def __init__(self, app_id): apiproxy_stub.APIProxyStub.__init__(self, SERVICE_NAME) self.__app_id = app_id self.__entity_converter = datastore_pbs.get_entity_converter() self.__service_validator = datastore_v4_validator.get_service_validator()