Example #1
0
    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)))
Example #2
0
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)
Example #3
0
    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))
Example #4
0
 def thumbnail(self):
     return str(PhotoData.get(self.id).thumbnail)
Example #5
0
 def img(self):
     return str(PhotoData.get(self.id).img)
Example #6
0
 def title(self):
     return PhotoData.get(self.id).title
Example #7
0
 def thumbnail(self):
     """Return the thumbnail data"""
     return str(PhotoData.get(self.id).thumbnail)
Example #8
0
 def img(self):
     """Return the image data"""
     return str(PhotoData.get(self.id).img)
Example #9
0
 def title(self):
     """Return the title of the photo"""
     return PhotoData.get(self.id).title