Exemplo n.º 1
0
    if 'state' in photo:
        if photo['state'] == PF.MARKED:
            style = 'border: solid red 1px'

    page.a(href=url, target='_blank', onMouseover="showmenu(event, '%s', '180px', '%s');"%(id, url), onMouseout="delayhidemenu()")
    page.img(src=photo['url_sq'], alt="%s (%s) : %s"%(username, user_id, id), style=style)
    # page.img(src='proxy.py?%s'%urllib.urlencode({"url":photo['url_sq']}), alt="%s (%s) : %s"%(username, user_id, id), style=style)
    page.a.close()

###########################################
page = FDH_page()
page.init(css = ('/styles/favorites.css'), header="Favorites (page %i)"%page_num)
page.script('', src='/javascript/menu2.js', type='text/javascript')
page.script('', src='/javascript/ajax.js', type='text/javascript')

manager = PhotoManager(FavoritesBackup())
photos = manager.getPhotos()

page.div()

if page_num != 0:
    page.a("Previous", href='favorites.py?%s'%urllib.urlencode({ 'page_num':page_num-1, 'perpage':perpage, 'user_id':user_id }))

if (page_num+1)*perpage < len(photos):
    page.a("Next", href='favorites.py?%s'%urllib.urlencode({ 'page_num':page_num+1, 'perpage':perpage, 'user_id':user_id }))

page.a("Export", href="favorites_action.py?action=export")

page.div.close()

lproxy = LocalProxy()
Logger().setup()

proxy = FDHProxySettings()
proxy.setValues(OPT)
proxy.activate()

form = cgi.FieldStorage()

photo_id = None
action = None

if 'photo_id' in form: photo_id = form['photo_id'].value
if 'action' in form: action = form['action'].value

###########################################
manager = PhotoManager(FavoritesBackup())

if action == 'mark' and photo_id != None:
    Logger().debug("marking %s"%photo_id)
    manager.markPhoto(photo_id)

if action == 'delete' and photo_id != None:
    Logger().debug("deleting %s"%photo_id)
    manager.removePhoto(photo_id)

if action == 'export':
    Logger().debug("exporting the list of photos")
    photos_id = map(lambda p:p['id'], manager.getPhotos())
    print "Content-type: text/txt\n\n"
    print "\n".join(photos_id)