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(sid=None) if input.sid: # Load source by ID. source_collection = UserSources.get_user_source_collection(users.get_current_user()) source = UserSource.get_by_id(long(input.sid), source_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: # No source selected. return None
def get_source(self): # Helper function to get the source object from the URL. input = web.input(sid=None) if input.sid: # Load source by ID. source_collection = UserSources.get_user_source_collection( users.get_current_user()) source = UserSource.get_by_id(long(input.sid), source_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: # No source selected. return None
def get_sources(self): return UserSource.get_by_id(self.sources, self)