def get_source(key): pointer = SourcePointer.get_pointer(key) if pointer: source_collection = UserSources.get_user_source_collection(pointer.owner) source = UserSource.get_by_id(pointer.sourceId, source_collection) return source else: return None
def get_source(key): pointer = SourcePointer.get_pointer(key) if pointer: source_collection = UserSources.get_user_source_collection( pointer.owner) source = UserSource.get_by_id(pointer.sourceId, source_collection) return source else: return None
def get_source(self): # Helper function to get the source object from the URL. input = web.input(id=None) collection = UserSources.get_user_source_collection(users.get_current_user()) if input.id: # Load source by ID. source = UserSource.get_by_id(long(input.id), collection) if not source: # It does not exist. raise web.notfound() # Check that the source belongs to the logged in user. if source.owner.user_id() != users.get_current_user().user_id(): # It's not theirs. 404. raise web.notfound() return source else: # New source. source = UserSource.factory(collection) return source
def get_source(self): # Helper function to get the source object from the URL. input = web.input(id=None) collection = UserSources.get_user_source_collection( users.get_current_user()) if input.id: # Load source by ID. source = UserSource.get_by_id(long(input.id), collection) if not source: # It does not exist. raise web.notfound() # Check that the source belongs to the logged in user. if source.owner.user_id() != users.get_current_user().user_id(): # It's not theirs. 404. raise web.notfound() return source else: # New source. source = UserSource.factory(collection) return source
def get_sources(self): return UserSource.get_by_id(self.sources, self)