def revobject_insert(self, request): my_items = ReviewObjectMessageCollection(items=request.items) for item in my_items.items: query = ReviewObjectModel.query(ReviewObjectModel.uuid == item.uuid) if query.count() == 0: ReviewObjectModel( name=item.name, description=item.description, creator=item.creator, lat=item.lat, lon=item.lon, tags=item.tags, last_modified=date_to_utc(item.last_modified), uuid=item.uuid, deleted=item.deleted, ).put() else: revobj = query.get() revobj.name = item.name revobj.description = item.description revobj.creator = item.creator revobj.lat = item.lat revobj.lon = item.lon revobj.tags = item.tags revobj.last_modified = date_to_utc(item.last_modified) revobj.deleted = item.deleted revobj.put() return message_types.VoidMessage()
def revobject_list(self, unused_request): qry = ReviewObjectModel.query() my_items = [] for rev in qry: my_items.append( ReviewObjectMessage( name=rev.name, description=rev.description, creator=rev.creator, lat=rev.lat, lon=rev.lon, tags=rev.tags, last_modified=rev.last_modified, uuid=rev.uuid, deleted=rev.deleted, ) ) return ReviewObjectMessageCollection(items=my_items)
def revobject_sync_down(self, request): query = ReviewObjectModel.query(ReviewObjectModel.last_modified > string_to_datetime(request.date)) my_items = [] for rev in query: my_items.append( ReviewObjectMessage( name=rev.name, description=rev.description, creator=rev.creator, lat=rev.lat, lon=rev.lon, tags=rev.tags, last_modified=rev.last_modified, uuid=rev.uuid, deleted=rev.deleted, ) ) return ReviewObjectMessageCollection(items=my_items)