def get_blobs(cls): # This function acts as a getter from in-memory storage. blobs = tools.mem_temp_get(settings.BLOBKEYMANAGER_KEY, None) if blobs is None: tools.mem_temp_set(settings.BLOBKEYMANAGER_KEY, {'delete': []}) blobs = tools.mem_temp_get(settings.BLOBKEYMANAGER_KEY) return blobs
def process_blob_output(cls): blobs = tools.mem_temp_get(settings.BLOBKEYMANAGER_KEY, None) if blobs is not None: save_blobs = blobs.get('save', None) delete_blobs = blobs.get('delete', None) if delete_blobs: if save_blobs: for blob in save_blobs: if blob in delete_blobs: delete_blobs.remove(blob) if delete_blobs: tools.log.debug('DELETED %s BLOBS.' % len(delete_blobs)) blobstore.delete(delete_blobs)
def prepare(self, **kwds): key_id = self.key_id parent = kwds.get('parent') self.set_key(key_id, parent=parent) if key_id is None and self.sequence is None: key = 'prepare_%s' % self.key.urlsafe() sequence = tools.mem_temp_get(key, tools.Nonexistent) if sequence is tools.Nonexistent: entity = self.query(ancestor=self.key.parent()).order( -self.__class__.sequence).get() if not entity: sequence = 0 else: sequence = entity.sequence tools.mem_temp_set(key, sequence) self.sequence = self._sequence + sequence + 1
def process_blob_state(cls, state): blobs = tools.mem_temp_get(settings.BLOBKEYMANAGER_KEY, None) if blobs is not None: # Process blobs to be saved. save_state_blobs = blobs.get('save_%s' % state, None) delete_blobs = blobs.get('delete', None) if delete_blobs is None: delete_blobs = blobs['delete'] = [] if save_state_blobs and delete_blobs is not None: for blob in save_state_blobs: if blob in delete_blobs: delete_blobs.remove(blob) # Process blobs to be deleted. delete_state_blobs = blobs.get('delete_%s' % state, None) if delete_state_blobs and delete_blobs is not None: for blob in delete_state_blobs: if blob not in delete_blobs: delete_blobs.append(blob)
def current_location_data(cls): return tools.mem_temp_get('current_request_location_data')
def current_account_session(cls): return tools.mem_temp_get('current_account_session')
def current_account(cls): current_account = tools.mem_temp_get('current_account') if not current_account: current_account = cls() cls.set_current_account(current_account) return current_account
def _is_cron(self): return tools.mem_temp_get('current_request_is_cron')
def _is_taskqueue(self): return tools.mem_temp_get('current_request_is_taskqueue')