def get_notebook(owner_nickname, notebook_access, notebook_name, notebook_version): """ Returns the notebook. """ content = "" #content of the book # calculate the key to retrieve content from db #import pdb; pdb.set_trace() key_name=owner_nickname+"/"+notebook_access+"/"+notebook_name #import pdb; pdb.set_trace() # if version is not specified return the latest one from NoteBook if notebook_version == "" or notebook_version is None: key = db.Key.from_path("NoteBook", key_name) else: # return the required version from NoteBookVersion # Add version to the key to retrieve a saved version key = db.Key.from_path("NoteBookVersion", key_name+"/"+str(notebook_version) ) if not key: return None notebook = NoteBook.get( key ) # get the notebook. if notebook: # if notebook is found return notebook # return it. else: return NoteBookVersion.get( key )