~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/action/bookmark.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - set or delete bookmarks (in time) for RecentChanges
 
4
 
 
5
    @copyright: 2000-2004 by Juergen Hermann <jh@web.de>,
 
6
                2006 by MoinMoin:ThomasWaldmann
 
7
    @license: GNU GPL, see COPYING for details.
 
8
"""
 
9
import time
 
10
 
 
11
from MoinMoin import wikiutil
 
12
from MoinMoin.Page import Page
 
13
 
 
14
def execute(pagename, request):
 
15
    """ set bookmarks (in time) for RecentChanges or delete them """
 
16
    _ = request.getText
 
17
    if not request.user.valid:
 
18
        actname = __name__.split('.')[-1]
 
19
        request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
 
20
        return Page(request, pagename).send_page()
 
21
 
 
22
    timestamp = request.form.get('time', [None])[0]
 
23
    if timestamp is not None:
 
24
        if timestamp == 'del':
 
25
            tm = None
 
26
        else:
 
27
            try:
 
28
                tm = int(timestamp)
 
29
            except StandardError:
 
30
                tm = wikiutil.timestamp2version(time.time())
 
31
    else:
 
32
        tm = wikiutil.timestamp2version(time.time())
 
33
 
 
34
    if tm is None:
 
35
        request.user.delBookmark()
 
36
    else:
 
37
        request.user.setBookmark(tm)
 
38
    request.page.send_page()