Back to index

moin  1.9.0~rc2
bookmark.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - set or delete bookmarks (in time) for RecentChanges
00004 
00005     @copyright: 2000-2004 by Juergen Hermann <jh@web.de>,
00006                 2006 by MoinMoin:ThomasWaldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 import time
00010 
00011 from MoinMoin import wikiutil
00012 from MoinMoin.Page import Page
00013 
00014 def execute(pagename, request):
00015     """ set bookmarks (in time) for RecentChanges or delete them """
00016     _ = request.getText
00017     if not request.user.valid:
00018         actname = __name__.split('.')[-1]
00019         request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
00020         return Page(request, pagename).send_page()
00021 
00022     timestamp = request.values.get('time')
00023     if timestamp is not None:
00024         if timestamp == 'del':
00025             tm = None
00026         else:
00027             try:
00028                 tm = int(timestamp)
00029             except StandardError:
00030                 tm = wikiutil.timestamp2version(time.time())
00031     else:
00032         tm = wikiutil.timestamp2version(time.time())
00033 
00034     if tm is None:
00035         request.user.delBookmark()
00036     else:
00037         request.user.setBookmark(tm)
00038     request.page.send_page()