def workspace_test(): print_data('workspaces objects', br=False) for index in range(3): w = Workspace() w.name = 'New workspace name' w.description = 'Some new description' w.save() workspaces = Workspace.all() print_data('new objects -> model.all()', workspaces) w.name = 'Updated name' w.save() workspaces = Workspace.all() print_data('UPDATED -> model.all()', workspaces) workspaces = Workspace.get(id=w.id, name=w.name) print_data('GET -> model.get()', [workspaces]) workspaces = Workspace.filter(name='New workspace name') print_data('FILTER -> model.filter()', workspaces) for index in range(2): o = Application() o.workspace_id = w.guid o.save() a = View() a.application_id = o.guid a.save() a = Resource() a.application_id = o.guid a.save() for index in range(3): o = Widget() o.workspace_id = w.guid o.save() for index in range(3): o = DataSource() o.workspace_id = w.guid o.save() objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all() print_data('All objects in db', objects) # [w.delete() for w in Workspace.all()] workspaces = Workspace.all() print_data('cleaned', workspaces) workspaces = Workspace.filter(include_deleted=True) print_data('cleaned with deleted if exists', workspaces) objects = Workspace.all() + Resource.all() + Application.all() + Widget.all() + DataSource.all() + View.all() print_data('no objects left', objects)
def getCollage(): collage = "%s/scripts/img/mincportfolio.png" % (access.server_url) try: result = None if Resource.all().count() == 1: for resource in Resource.all(): result = resource.resource_key.key() collage = "%s/serve/%s" % (access.server_url, result) return collage else: return collage except: return collage
def fetch_request_token(self, oauth_consumer, oauth_callback): logger.warning("!!! In MockOAuthDataStore.fetch_request_token args: %s"%locals()) if oauth_consumer.key != self.consumer.key: raise OAuthError('Consumer key does not match.') # OAuth 1.0a: if there is a callback, check its validity callback = None callback_confirmed = False if oauth_callback: if oauth_callback != OUT_OF_BAND: if check_valid_callback(oauth_callback): callback = oauth_callback callback_confirmed = True else: raise oauth.OAuthError('Invalid callback URL.') #not going to implement scope just yet-so just hard code this for now resource = Resource.all().filter("name =","default")[0] #try: # resource = Resource.objects.get(name=self.scope) #except: # raise OAuthError('Resource %s does not exist.' % escape(self.scope)) self.request_token = Token.create_token(consumer=self.consumer, token_type=Token.REQUEST, timestamp=self.timestamp, resource=resource, callback=callback, callback_confirmed=callback_confirmed) return self.request_token