def add_photo(self, comp): r = comp.call(PhotoCreator()) if r is not None: (title, img) = r gallery = GalleryData.get_by(name=self.name) gallery.photos.append(PhotoData(title=title, img=img, thumbnail=thumb.thumbnail(img)))
def init(self, url, comp, *args): # The URL received is the name of the photo photo_data = PhotoData.get_by(title=url[0]) if not photo_data: # A photo with this name doesn't exist raise presentation.HTTPNotFound() # Get the photo data and make a ``Photo`` component photo = component.Component(Photo(photo_data.id)) # Temporary change the Gallery (the ``comp``) with the photo continuation.Continuation(comp.call, photo)
def add_photo(self, comp): """This method temporary replaces the Gallery component by a PhotoCreator component. Upon submission of a photo, the PhotoCreator answers with the title and the uploaded image""" # Change the Gallery by a PhotoCreator component r = comp.call(PhotoCreator()) if r is not None: # If the user click on the the "Cancel" button, we receive ``None`` # else we receive the title and the uploaded image (title, img) = r # Insert these data into the database gallery = GalleryData.get_by(name=self.name) gallery.photos.append( PhotoData(title=title, img=img, thumbnail=img))
def thumbnail(self): return str(PhotoData.get(self.id).thumbnail)
def img(self): return str(PhotoData.get(self.id).img)
def title(self): return PhotoData.get(self.id).title
def thumbnail(self): """Return the thumbnail data""" return str(PhotoData.get(self.id).thumbnail)
def img(self): """Return the image data""" return str(PhotoData.get(self.id).img)
def title(self): """Return the title of the photo""" return PhotoData.get(self.id).title