Ejemplo n.º 1
0
 def get(self):
     '''no arguments'''
     today = datetime.today()
     query = Picture.all().filter('uploaded >', 
             datetime(today.year, today.month, today.day, 0, 0)
     )
     if query.count():
         logging.debug('New pictures for newsletter: %s' % query.count())
         pictures_today = list(query)
         query = Subscription.all().filter('active =', True)
         if query.count():
             logging.info('Sending newsletter to %s recipients' %
                     query.count())
             recipients = list(query)
             today = datetime.today()
             message = mail.EmailMessage()
             message.sender = '%s (Photoblog) <%s>' % (
                     conf.mail_from_name,
                     conf.mail_from_address
             )
             message.to = conf.mail_from_address
             message.bcc = [r.email for r in recipients]
             message.subject = conf.mail_newsletter_subject
             message.body = render('newsletter.txt', {'pics':pictures_today})
             message.send()
Ejemplo n.º 2
0
 def get(self, gphoto_id=None):
     '''display the picture
     @param gphoto_id: the numeric ID from picasa
     '''
     if not gphoto_id:
         query = Picture.gql('ORDER BY uploaded DESC LIMIT 1')
         latest_picture = query.get()
         gphoto_id = str(latest_picture.gphoto_id)
     page = memcache.get(gphoto_id, namespace='pics')
     if page is None:
         pics = Picture.all().filter('gphoto_id =', int(gphoto_id))
         pic = pics.get()
         logging.debug('Picture view: %s' % pic.gphoto_id)
         page = render('pic.html', {'pic':pic,
                                     'next':get_newer(pic),
                                     'prev':get_older(pic)
         })
         if not memcache.add(gphoto_id, page, 86400, namespace='pics'):
             logging.error('Page %s not written to memcache' % gphoto_id)
         else:
             logging.debug('New memcache entry: %s' % gphoto_id)
     self.response.out.write(page)
Ejemplo n.º 3
0
 def get(self):
     pics = Picture.all()
     values = {'pics':pics}
     self.generateBasePage('manage/pics.html', values)
     return