Mercurial > public > src > moin > 1.9
annotate MoinMoin/user.py @ 2065:23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
author | Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl> |
---|---|
date | Thu, 31 May 2007 01:01:35 +0200 |
parents | a7fb50fd67f6 |
children | 9fec7760489e |
rev | line source |
---|---|
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
1 # -*- coding: iso-8859-1 -*- |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
2 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
3 MoinMoin - User Accounts |
1909
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
4 |
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
5 This module contains functions to access user accounts (list all users, get |
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
6 some specific user). User instances are used to access the user profile of |
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
7 some specific user (name, password, email, bookmark, trail, settings, ...). |
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
8 |
be140a589f11
improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1868
diff
changeset
|
9 The UserPreferences form support stuff is in module userform. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
10 |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
11 TODO: |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
12 * code is a mixture of highlevel user stuff and lowlevel storage functions, |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
13 this has to get separated into: |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
14 * user object highlevel stuff |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
15 * storage code |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
16 |
1918
bb2e053067fb
fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1909
diff
changeset
|
17 @copyright: 2000-2004 Juergen Hermann <jh@web.de>, |
bb2e053067fb
fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1909
diff
changeset
|
18 2003-2007 MoinMoin:ThomasWaldmann |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
19 @license: GNU GPL, see COPYING for details. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
20 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
21 |
1075
2ecd1e6c084d
Fixed security issues in MoinMoin.user (do not reveal the ID), added variable hiding to cgitb.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1005
diff
changeset
|
22 # add names here to hide them in the cgitb traceback |
2ecd1e6c084d
Fixed security issues in MoinMoin.user (do not reveal the ID), added variable hiding to cgitb.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1005
diff
changeset
|
23 unsafe_names = ("id", "key", "val", "user_data", "enc_password") |
2ecd1e6c084d
Fixed security issues in MoinMoin.user (do not reveal the ID), added variable hiding to cgitb.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1005
diff
changeset
|
24 |
232
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
25 import os, time, sha, codecs |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
26 |
688
15c55ecd7ccb
fix some i18n bugs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
684
diff
changeset
|
27 from MoinMoin import config, caching, wikiutil, i18n |
1801
3369445b4aa8
move the dircache stuff to MoinMoin.util.filesys and disable it on win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1791
diff
changeset
|
28 from MoinMoin.util import timefuncs, filesys |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
29 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
30 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
31 def getUserList(request): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
32 """ Get a list of all (numerical) user IDs. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
33 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
34 @param request: current request |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
35 @rtype: list |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
36 @return: all user IDs |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
37 """ |
1801
3369445b4aa8
move the dircache stuff to MoinMoin.util.filesys and disable it on win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1791
diff
changeset
|
38 import re |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
39 user_re = re.compile(r'^\d+\.\d+(\.\d+)?$') |
1801
3369445b4aa8
move the dircache stuff to MoinMoin.util.filesys and disable it on win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1791
diff
changeset
|
40 files = filesys.dclistdir(request.cfg.user_dir) |
232
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
41 userlist = [f for f in files if user_re.match(f)] |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
42 return userlist |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
43 |
690
e8ccec07515b
Refactored user search by mail address.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
626
diff
changeset
|
44 def get_by_email_address(request, email_address): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
45 """ Searches for a user with a particular e-mail address and returns it. """ |
690
e8ccec07515b
Refactored user search by mail address.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
626
diff
changeset
|
46 for uid in getUserList(request): |
e8ccec07515b
Refactored user search by mail address.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
626
diff
changeset
|
47 theuser = User(request, uid) |
e8ccec07515b
Refactored user search by mail address.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
626
diff
changeset
|
48 if theuser.valid and theuser.email.lower() == email_address.lower(): |
e8ccec07515b
Refactored user search by mail address.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
626
diff
changeset
|
49 return theuser |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
50 |
2011
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
51 def _getUserIdByKey(request, key, search): |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
52 """ Get the user ID for a specified key/value pair. |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
53 |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
54 This method must only be called for keys that are |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
55 guaranteed to be unique. |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
56 |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
57 @param key: the key to look in |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
58 @param search: the value to look for |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
59 @return the corresponding user ID or None |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
60 """ |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
61 if not search or not key: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
62 return None |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
63 cfg = request.cfg |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
64 cachekey = '%s2id' % key |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
65 try: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
66 _key2id = getattr(cfg.cache, cachekey) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
67 except AttributeError: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
68 arena = 'user' |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
69 cache = caching.CacheEntry(request, arena, cachekey, scope='wiki', use_pickle=True) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
70 try: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
71 _key2id = cache.content() |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
72 except caching.CacheError: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
73 _key2id = {} |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
74 setattr(cfg.cache, cachekey, _key2id) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
75 uid = _key2id.get(search, None) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
76 if uid is None: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
77 for userid in getUserList(request): |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
78 u = User(request, id=userid) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
79 if hasattr(u, key): |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
80 value = getattr(u, key) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
81 _key2id[value] = userid |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
82 arena = 'user' |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
83 cache = caching.CacheEntry(request, arena, cachekey, scope='wiki', use_pickle=True) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
84 try: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
85 cache.update(_key2id) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
86 except caching.CacheError: |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
87 pass |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
88 uid = _key2id.get(search, None) |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
89 return uid |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
90 |
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
91 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
92 def getUserId(request, searchName): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
93 """ Get the user ID for a specific user NAME. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
94 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
95 @param searchName: the user name to look up |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
96 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
97 @return: the corresponding user ID or None |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
98 """ |
2011
6cd0e4cc8e18
refactor user.getUserId
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
2010
diff
changeset
|
99 return _getUserIdByKey(request, 'name', searchName) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
100 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
101 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
102 def getUserIdentification(request, username=None): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
103 """ Return user name or IP or '<unknown>' indicator. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
104 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
105 @param request: the request object |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
106 @param username: (optional) user name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
107 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
108 @return: user name or IP or unknown indicator |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
109 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
110 _ = request.getText |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
111 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
112 if username is None: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
113 username = request.user.name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
114 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
115 return username or (request.cfg.show_hosts and request.remote_addr) or _("<unknown>") |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
116 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
117 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
118 def encodePassword(pwd, charset='utf-8'): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
119 """ Encode a cleartext password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
120 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
121 Compatible to Apache htpasswd SHA encoding. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
122 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
123 When using different encoding than 'utf-8', the encoding might fail |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
124 and raise UnicodeError. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
125 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
126 @param pwd: the cleartext password, (unicode) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
127 @param charset: charset used to encode password, used only for |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
128 compatibility with old passwords generated on moin-1.2. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
129 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
130 @return: the password in apache htpasswd compatible SHA-encoding, |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
131 or None |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
132 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
133 import base64 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
134 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
135 # Might raise UnicodeError, but we can't do anything about it here, |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
136 # so let the caller handle it. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
137 pwd = pwd.encode(charset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
138 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
139 pwd = sha.new(pwd).digest() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
140 pwd = '{SHA}' + base64.encodestring(pwd).rstrip() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
141 return pwd |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
142 |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
143 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
144 def normalizeName(name): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
145 """ Make normalized user name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
146 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
147 Prevent impersonating another user with names containing leading, |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
148 trailing or multiple whitespace, or using invisible unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
149 characters. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
150 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
151 Prevent creating user page as sub page, because '/' is not allowed |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
152 in user names. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
153 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
154 Prevent using ':' and ',' which are reserved by acl. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
155 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
156 @param name: user name, unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
157 @rtype: unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
158 @return: user name that can be used in acl lines |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
159 """ |
826
8e880418d736
remove all underscore <-> blank magic
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
750
diff
changeset
|
160 username_allowedchars = "'@.-_" # ' for names like O'Brian or email addresses. |
8e880418d736
remove all underscore <-> blank magic
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
750
diff
changeset
|
161 # "," and ":" must not be allowed (ACL delimiters). |
8e880418d736
remove all underscore <-> blank magic
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
750
diff
changeset
|
162 # We also allow _ in usernames for nicer URLs. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
163 # Strip non alpha numeric characters (except username_allowedchars), keep white space |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
164 name = ''.join([c for c in name if c.isalnum() or c.isspace() or c in username_allowedchars]) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
165 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
166 # Normalize white space. Each name can contain multiple |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
167 # words separated with only one space. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
168 name = ' '.join(name.split()) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
169 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
170 return name |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
171 |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
172 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
173 def isValidName(request, name): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
174 """ Validate user name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
175 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
176 @param name: user name, unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
177 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
178 normalized = normalizeName(name) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
179 return (name == normalized) and not wikiutil.isGroupPage(request, name) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
180 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
181 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
182 def encodeList(items): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
183 """ Encode list of items in user data file |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
184 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
185 Items are separated by '\t' characters. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
186 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
187 @param items: list unicode strings |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
188 @rtype: unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
189 @return: list encoded as unicode |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
190 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
191 line = [] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
192 for item in items: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
193 item = item.strip() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
194 if not item: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
195 continue |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
196 line.append(item) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
197 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
198 line = '\t'.join(line) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
199 return line |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
200 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
201 def decodeList(line): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
202 """ Decode list of items from user data file |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
203 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
204 @param line: line containing list of items, encoded with encodeList |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
205 @rtype: list of unicode strings |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
206 @return: list of items in encoded in line |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
207 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
208 items = [] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
209 for item in line.split('\t'): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
210 item = item.strip() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
211 if not item: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
212 continue |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
213 items.append(item) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
214 return items |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
215 |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
216 def encodeDict(items): |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
217 """ Encode dict of items in user data file |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
218 |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
219 Items are separated by '\t' characters. |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
220 Each item is key:value. |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
221 |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
222 @param items: dict of unicode:unicode |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
223 @rtype: unicode |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
224 @return: dict encoded as unicode |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
225 """ |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
226 line = [] |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
227 for key, value in items.items(): |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
228 item = u'%s:%s' % (key, value) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
229 line.append(item) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
230 line = '\t'.join(line) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
231 return line |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
232 |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
233 def decodeDict(line): |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
234 """ Decode dict of key:value pairs from user data file |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
235 |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
236 @param line: line containing a dict, encoded with encodeDict |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
237 @rtype: dict |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
238 @return: dict unicode:unicode items |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
239 """ |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
240 items = {} |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
241 for item in line.split('\t'): |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
242 item = item.strip() |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
243 if not item: |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
244 continue |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
245 key, value = item.split(':', 1) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
246 items[key] = value |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
247 return items |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
248 |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
249 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
250 class User: |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
251 """ A MoinMoin User """ |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
252 |
265
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
253 def __init__(self, request, id=None, name="", password=None, auth_username="", **kw): |
244
42f749b0d8bb
fix empty username when using auth_username for autocreation
Thomas Waldmann <tw@waldmann-edv.de>
parents:
238
diff
changeset
|
254 """ Initialize User object |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
255 |
1986
3475126f78c6
fix some builtin names used as attribute names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1963
diff
changeset
|
256 TODO: when this gets refactored, use "uid" not builtin "id" |
3475126f78c6
fix some builtin names used as attribute names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1963
diff
changeset
|
257 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
258 @param request: the request object |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
259 @param id: (optional) user ID |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
260 @param name: (optional) user name |
1606
ae56d79ae076
http auth / ssl clientcert auth: correctly decode name/password/email to unicode (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1597
diff
changeset
|
261 @param password: (optional) user password (unicode) |
265
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
262 @param auth_username: (optional) already authenticated user name |
1606
ae56d79ae076
http auth / ssl clientcert auth: correctly decode name/password/email to unicode (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1597
diff
changeset
|
263 (e.g. when using http basic auth) (unicode) |
265
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
264 @keyword auth_method: method that was used for authentication, |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
265 default: 'internal' |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
266 @keyword auth_attribs: tuple of user object attribute names that are |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
267 determined by auth method and should not be |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
268 changed by UserPreferences form, default: (). |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
269 First tuple element was used for authentication. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
270 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
271 self._cfg = request.cfg |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
272 self.valid = 0 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
273 self.id = id |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
274 self.auth_username = auth_username |
265
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
275 self.auth_method = kw.get('auth_method', 'internal') |
2cbc7dc436d7
auth changes: added u.auth_method, u.auth_attribs and some debug code. Support for switching off some form fields.
Thomas Waldmann <tw@waldmann-edv.de>
parents:
244
diff
changeset
|
276 self.auth_attribs = kw.get('auth_attribs', ()) |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
277 self.bookmarks = {} # interwikiname: bookmark |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
278 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
279 # create some vars automatically |
737
87cf4c0aac44
hopefully fixes the css_url backtrace for new users when admin removed css_url form field
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
733
diff
changeset
|
280 self.__dict__.update(self._cfg.user_form_defaults) |
87cf4c0aac44
hopefully fixes the css_url backtrace for new users when admin removed css_url form field
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
733
diff
changeset
|
281 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
282 if name: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
283 self.name = name |
244
42f749b0d8bb
fix empty username when using auth_username for autocreation
Thomas Waldmann <tw@waldmann-edv.de>
parents:
238
diff
changeset
|
284 elif auth_username: # this is needed for user_autocreate |
42f749b0d8bb
fix empty username when using auth_username for autocreation
Thomas Waldmann <tw@waldmann-edv.de>
parents:
238
diff
changeset
|
285 self.name = auth_username |
266
1fb19804a4b9
removed some debug code
Thomas Waldmann <tw@waldmann-edv.de>
parents:
265
diff
changeset
|
286 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
287 # create checkbox fields (with default 0) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
288 for key, label in self._cfg.user_checkbox_fields: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
289 setattr(self, key, self._cfg.user_checkbox_defaults.get(key, 0)) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
290 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
291 self.enc_password = "" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
292 if password: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
293 if password.startswith('{SHA}'): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
294 self.enc_password = password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
295 else: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
296 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
297 self.enc_password = encodePassword(password) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
298 except UnicodeError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
299 pass # Should never happen |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
300 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
301 #self.edit_cols = 80 |
8 | 302 self.tz_offset = int(float(self._cfg.tz_offset) * 3600) |
303 self.language = "" | |
304 self.date_fmt = "" | |
305 self.datetime_fmt = "" | |
1689
7b80735ede14
quicklinks_default and subscribed_pages_default to preload the lists in the user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1638
diff
changeset
|
306 self.quicklinks = self._cfg.quicklinks_default |
7b80735ede14
quicklinks_default and subscribed_pages_default to preload the lists in the user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1638
diff
changeset
|
307 self.subscribed_pages = self._cfg.subscribed_pages_default |
8 | 308 self.theme_name = self._cfg.theme_default |
309 self.editor_default = self._cfg.editor_default | |
310 self.editor_ui = self._cfg.editor_ui | |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
311 self.last_saved = str(time.time()) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
312 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
313 # attrs not saved to profile |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
314 self._request = request |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
315 self._trail = [] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
316 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
317 # we got an already authenticated username: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
318 check_pass = 0 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
319 if not self.id and self.auth_username: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
320 self.id = getUserId(request, self.auth_username) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
321 if not password is None: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
322 check_pass = 1 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
323 if self.id: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
324 self.load_from_id(check_pass) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
325 elif self.name: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
326 self.id = getUserId(self._request, self.name) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
327 if self.id: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
328 self.load_from_id(1) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
329 else: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
330 self.id = self.make_id() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
331 else: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
332 self.id = self.make_id() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
333 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
334 # "may" so we can say "if user.may.read(pagename):" |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
335 if self._cfg.SecurityPolicy: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
336 self.may = self._cfg.SecurityPolicy(self) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
337 else: |
1535
6a7dd84b091f
Fixed evil relative import.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1430
diff
changeset
|
338 from MoinMoin.security import Default |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
339 self.may = Default(self) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
340 |
689
ff56d9861a71
yet another i18n fix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
688
diff
changeset
|
341 if self.language and not self.language in i18n.wikiLanguages(): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
342 self.language = 'en' |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
343 |
339 | 344 def __repr__(self): |
1075
2ecd1e6c084d
Fixed security issues in MoinMoin.user (do not reveal the ID), added variable hiding to cgitb.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1005
diff
changeset
|
345 return "<%s.%s at 0x%x name:%r valid:%r>" % ( |
339 | 346 self.__class__.__module__, self.__class__.__name__, |
1075
2ecd1e6c084d
Fixed security issues in MoinMoin.user (do not reveal the ID), added variable hiding to cgitb.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
1005
diff
changeset
|
347 id(self), self.name, self.valid) |
339 | 348 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
349 def make_id(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
350 """ make a new unique user id """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
351 #!!! this should probably be a hash of REMOTE_ADDR, HTTP_USER_AGENT |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
352 # and some other things identifying remote users, then we could also |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
353 # use it reliably in edit locking |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
354 from random import randint |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
355 return "%s.%d" % (str(time.time()), randint(0, 65535)) |
238
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
356 |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
357 def create_or_update(self, changed=False): |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
358 """ Create or update a user profile |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
359 |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
360 @param changed: bool, set this to True if you updated the user profile values |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
361 """ |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
362 if self._cfg.user_autocreate: |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
363 if not self.valid and not self.disabled or changed: # do we need to save/update? |
b80624429934
added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert
Thomas Waldmann <tw@waldmann-edv.de>
parents:
232
diff
changeset
|
364 self.save() # yes, create/update user profile |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
365 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
366 def __filename(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
367 """ Get filename of the user's file on disk |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
368 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
369 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
370 @return: full path and filename of user account file |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
371 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
372 return os.path.join(self._cfg.user_dir, self.id or "...NONE...") |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
373 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
374 def exists(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
375 """ Do we have a user account for this user? |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
376 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
377 @rtype: bool |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
378 @return: true, if we have a user account |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
379 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
380 return os.path.exists(self.__filename()) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
381 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
382 def load_from_id(self, check_pass=0): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
383 """ Load user account data from disk. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
384 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
385 Can only load user data if the id number is already known. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
386 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
387 This loads all member variables, except "id" and "valid" and |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
388 those starting with an underscore. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
389 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
390 @param check_pass: If 1, then self.enc_password must match the |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
391 password in the user account file. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
392 """ |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
393 if not self.exists(): |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
394 return |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
395 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
396 data = codecs.open(self.__filename(), "r", config.charset).readlines() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
397 user_data = {'enc_password': ''} |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
398 for line in data: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
399 if line[0] == '#': |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
400 continue |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
401 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
402 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
403 key, val = line.strip().split('=', 1) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
404 if key not in self._cfg.user_transient_fields and key[0] != '_': |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
405 # Decode list values |
1923
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
406 if key.endswith('[]'): |
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
407 key = key[:-2] |
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
408 val = decodeList(val) |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
409 # Decode dict values |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
410 elif key.endswith('{}'): |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
411 key = key[:-2] |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
412 val = decodeDict(val) |
1923
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
413 # for compatibility reading old files, keep these explicit |
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
414 # we will store them with [] appended |
eefebea247a0
user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1920
diff
changeset
|
415 elif key in ['quicklinks', 'subscribed_pages']: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
416 val = decodeList(val) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
417 user_data[key] = val |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
418 except ValueError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
419 pass |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
420 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
421 # Validate data from user file. In case we need to change some |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
422 # values, we set 'changed' flag, and later save the user data. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
423 changed = 0 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
424 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
425 if check_pass: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
426 # If we have no password set, we don't accept login with username |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
427 if not user_data['enc_password']: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
428 return |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
429 # Check for a valid password, possibly changing encoding |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
430 valid, changed = self._validatePassword(user_data) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
431 if not valid: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
432 return |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
433 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
434 # Remove ignored checkbox values from user data |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
435 for key, label in self._cfg.user_checkbox_fields: |
1868
64507f46beb2
reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1832
diff
changeset
|
436 if key in user_data and key in self._cfg.user_checkbox_disable: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
437 del user_data[key] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
438 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
439 # Copy user data into user object |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
440 for key, val in user_data.items(): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
441 vars(self)[key] = val |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
442 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
443 self.tz_offset = int(self.tz_offset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
444 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
445 # Remove old unsupported attributes from user data file. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
446 remove_attributes = ['passwd', 'show_emoticons'] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
447 for attr in remove_attributes: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
448 if hasattr(self, attr): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
449 delattr(self, attr) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
450 changed = 1 |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
451 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
452 # make sure checkboxes are boolean |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
453 for key, label in self._cfg.user_checkbox_fields: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
454 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
455 setattr(self, key, int(getattr(self, key))) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
456 except ValueError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
457 setattr(self, key, 0) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
458 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
459 # convert (old) hourly format to seconds |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
460 if -24 <= self.tz_offset and self.tz_offset <= 24: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
461 self.tz_offset = self.tz_offset * 3600 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
462 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
463 # clear trail |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
464 self._trail = [] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
465 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
466 if not self.disabled: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
467 self.valid = 1 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
468 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
469 # If user data has been changed, save fixed user data. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
470 if changed: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
471 self.save() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
472 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
473 def _validatePassword(self, data): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
474 """ Try to validate user password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
475 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
476 This is a private method and should not be used by clients. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
477 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
478 In pre 1.3, the wiki used some 8 bit charset. The user password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
479 was entered in this 8 bit password and passed to |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
480 encodePassword. So old passwords can use any of the charset |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
481 used. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
482 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
483 In 1.3, we use unicode internally, so we encode the password in |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
484 encodePassword using utf-8. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
485 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
486 When we compare passwords we must compare with same encoding, or |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
487 the passwords will not match. We don't know what encoding the |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
488 password on the user file uses. We may ask the wiki admin to put |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
489 this into the config, but he may be wrong. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
490 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
491 The way chosen is to try to encode and compare passwords using |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
492 all the encoding that were available on 1.2, until we get a |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
493 match, which means that the user is valid. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
494 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
495 If we get a match, we replace the user password hash with the |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
496 utf-8 encoded version, and next time it will match on first try |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
497 as before. The user password did not change, this change is |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
498 completely transparent for the user. Only the sha digest will |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
499 change. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
500 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
501 @param data: dict with user data |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
502 @rtype: 2 tuple (bool, bool) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
503 @return: password is valid, password did change |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
504 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
505 # First try with default encoded password. Match only non empty |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
506 # passwords. (require non empty enc_password) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
507 if self.enc_password and self.enc_password == data['enc_password']: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
508 return True, False |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
509 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
510 # Try to match using one of pre 1.3 8 bit charsets |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
511 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
512 # Get the clear text password from the form (require non empty |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
513 # password) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
514 password = self._request.form.get('password', [None])[0] |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
515 if not password: |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
516 return False, False |
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
517 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
518 # First get all available pre13 charsets on this system |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
519 pre13 = ['iso-8859-1', 'iso-8859-2', 'euc-jp', 'gb2312', 'big5', ] |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
520 available = [] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
521 for charset in pre13: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
522 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
523 encoder = codecs.getencoder(charset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
524 available.append(charset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
525 except LookupError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
526 pass # missing on this system |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
527 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
528 # Now try to match the password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
529 for charset in available: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
530 # Try to encode, failure is expected |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
531 try: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
532 enc_password = encodePassword(password, charset=charset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
533 except UnicodeError: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
534 continue |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
535 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
536 # And match (require non empty enc_password) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
537 if enc_password and enc_password == data['enc_password']: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
538 # User password match - replace the user password in the |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
539 # file with self.password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
540 data['enc_password'] = self.enc_password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
541 return True, True |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
542 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
543 # No encoded password match, this must be wrong password |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
544 return False, False |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
545 |
1951
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
546 def persistent_items(self): |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
547 """ items we want to store into the user profile """ |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
548 return [(key, value) for key, value in vars(self).items() |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
549 if key not in self._cfg.user_transient_fields and key[0] != '_'] |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
550 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
551 def save(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
552 """ Save user account data to user account file on disk. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
553 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
554 This saves all member variables, except "id" and "valid" and |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
555 those starting with an underscore. |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
556 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
557 if not self.id: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
558 return |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
559 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
560 user_dir = self._cfg.user_dir |
1430
fd7166892bd3
check for non-existing dir before calling os.makedirs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1428
diff
changeset
|
561 if not os.path.exists(user_dir): |
fd7166892bd3
check for non-existing dir before calling os.makedirs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1428
diff
changeset
|
562 os.makedirs(user_dir) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
563 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
564 self.last_saved = str(time.time()) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
565 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
566 # !!! should write to a temp file here to avoid race conditions, |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
567 # or even better, use locking |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
568 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
569 data = codecs.open(self.__filename(), "w", config.charset) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
570 data.write("# Data saved '%s' for id '%s'\n" % ( |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
571 time.strftime(self._cfg.datetime_fmt, time.localtime(time.time())), |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
572 self.id)) |
1951
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
573 attrs = self.persistent_items() |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
574 attrs.sort() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
575 for key, value in attrs: |
1951
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
576 # Encode list values |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
577 if isinstance(value, list): |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
578 key += '[]' |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
579 value = encodeList(value) |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
580 # Encode dict values |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
581 elif isinstance(value, dict): |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
582 key += '{}' |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
583 value = encodeDict(value) |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
584 line = u"%s=%s\n" % (key, unicode(value)) |
a05a3b447db5
interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1940
diff
changeset
|
585 data.write(line) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
586 data.close() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
587 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
588 if not self.disabled: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
589 self.valid = 1 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
590 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
591 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
592 # Time and date formatting |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
593 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
594 def getTime(self, tm): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
595 """ Get time in user's timezone. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
596 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
597 @param tm: time (UTC UNIX timestamp) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
598 @rtype: int |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
599 @return: tm tuple adjusted for user's timezone |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
600 """ |
476
4be11eec9c4f
MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
Thomas Waldmann <tw@waldmann-edv.de>
parents:
449
diff
changeset
|
601 return timefuncs.tmtuple(tm + self.tz_offset) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
602 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
603 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
604 def getFormattedDate(self, tm): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
605 """ Get formatted date adjusted for user's timezone. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
606 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
607 @param tm: time (UTC UNIX timestamp) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
608 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
609 @return: formatted date, see cfg.date_fmt |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
610 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
611 date_fmt = self.date_fmt or self._cfg.date_fmt |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
612 return time.strftime(date_fmt, self.getTime(tm)) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
613 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
614 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
615 def getFormattedDateTime(self, tm): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
616 """ Get formatted date and time adjusted for user's timezone. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
617 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
618 @param tm: time (UTC UNIX timestamp) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
619 @rtype: string |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
620 @return: formatted date and time, see cfg.datetime_fmt |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
621 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
622 datetime_fmt = self.datetime_fmt or self._cfg.datetime_fmt |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
623 return time.strftime(datetime_fmt, self.getTime(tm)) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
624 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
625 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
626 # Bookmark |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
627 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
628 def setBookmark(self, tm): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
629 """ Set bookmark timestamp. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
630 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
631 @param tm: timestamp |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
632 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
633 if self.valid: |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
634 interwikiname = unicode(self._cfg.interwikiname or '') |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
635 bookmark = unicode(tm) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
636 self.bookmarks[interwikiname] = bookmark |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
637 self.save() |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
638 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
639 def getBookmark(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
640 """ Get bookmark timestamp. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
641 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
642 @rtype: int |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
643 @return: bookmark timestamp or None |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
644 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
645 bm = None |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
646 interwikiname = unicode(self._cfg.interwikiname or '') |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
647 if self.valid: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
648 try: |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
649 bm = int(self.bookmarks[interwikiname]) |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
650 except (ValueError, KeyError): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
651 pass |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
652 return bm |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
653 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
654 def delBookmark(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
655 """ Removes bookmark timestamp. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
656 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
657 @rtype: int |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
658 @return: 0 on success, 1 on failure |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
659 """ |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
660 interwikiname = unicode(self._cfg.interwikiname or '') |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
661 if self.valid: |
1940
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
662 try: |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
663 del self.bookmarks[interwikiname] |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
664 except KeyError: |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
665 return 1 |
d7296d36e6f0
enable user storage code to save simple dicts to user profile, use that to save RC bookmarks into user profile
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1935
diff
changeset
|
666 self.save() |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
667 return 0 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
668 return 1 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
669 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
670 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
671 # Subscribe |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
672 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
673 def getSubscriptionList(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
674 """ Get list of pages this user has subscribed to |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
675 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
676 @rtype: list |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
677 @return: pages this user has subscribed to |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
678 """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
679 return self.subscribed_pages |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
680 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
681 def isSubscribedTo(self, pagelist): |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
682 """ Check if user subscription matches any page in pagelist. |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
683 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
684 The subscription list may contain page names or interwiki page |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
685 names. e.g 'Page Name' or 'WikiName:Page_Name' |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
686 |
94
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
687 TODO: check if its fast enough when calling with many users |
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
688 from page.getSubscribersList() |
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
689 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
690 @param pagelist: list of pages to check for subscription |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
691 @rtype: bool |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
692 @return: if user is subscribed any page in pagelist |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
693 """ |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
694 if not self.valid: |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
695 return False |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
696 |
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
697 import re |
94
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
698 # Create a new list with both names and interwiki names. |
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
699 pages = pagelist[:] |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
700 if self._cfg.interwikiname: |
94
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
701 pages += [self._interWikiName(pagename) for pagename in pagelist] |
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
702 # Create text for regular expression search |
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
703 text = '\n'.join(pages) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
704 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
705 for pattern in self.getSubscriptionList(): |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
706 # Try simple match first |
94
7f531b511f2e
fix isSubscribedTo when calling multiple times, for example from page.getSubscribersList()
Nir Soffer <nirs@freeshell.org>
parents:
90
diff
changeset
|
707 if pattern in pages: |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
708 return True |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
709 # Try regular expression search, skipping bad patterns |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
710 try: |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
711 pattern = re.compile(r'^%s$' % pattern, re.M) |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
712 except re.error: |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
713 continue |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
714 if pattern.search(text): |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
715 return True |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
716 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
717 return False |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
718 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
719 def subscribe(self, pagename): |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
720 """ Subscribe to a wiki page. |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
721 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
722 To enable shared farm users, if the wiki has an interwiki name, |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
723 page names are saved as interwiki names. |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
724 |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
725 @param pagename: name of the page to subscribe |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
726 @type pagename: unicode |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
727 @rtype: bool |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
728 @return: if page was subscribed |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
729 """ |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
730 if self._cfg.interwikiname: |
121
e61a09408702
fix name error in user.subscribe
Nir Soffer <nirs@freeshell.org>
parents:
94
diff
changeset
|
731 pagename = self._interWikiName(pagename) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
732 |
121
e61a09408702
fix name error in user.subscribe
Nir Soffer <nirs@freeshell.org>
parents:
94
diff
changeset
|
733 if pagename not in self.subscribed_pages: |
e61a09408702
fix name error in user.subscribe
Nir Soffer <nirs@freeshell.org>
parents:
94
diff
changeset
|
734 self.subscribed_pages.append(pagename) |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
735 self.save() |
2065
23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
2035
diff
changeset
|
736 |
23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
2035
diff
changeset
|
737 # Send a notification |
23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
2035
diff
changeset
|
738 from MoinMoin.events import SubscribedToPageEvent, send_event |
23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
2035
diff
changeset
|
739 e = SubscribedToPageEvent(self._request, pagename, self.name) |
23d90aae61b5
Send events when an user subscribes to a page and when page gets reverted.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents:
2035
diff
changeset
|
740 send_event(e) |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
741 return True |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
742 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
743 return False |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
744 |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
745 def unsubscribe(self, pagename): |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
746 """ Unsubscribe a wiki page. |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
747 |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
748 Try to unsubscribe by removing non-interwiki name (leftover |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
749 from old use files) and interwiki name from the subscription |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
750 list. |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
751 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
752 Its possible that the user will be subscribed to a page by more |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
753 then one pattern. It can be both pagename and interwiki name, |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
754 or few patterns that all of them match the page. Therefore, we |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
755 must check if the user is still subscribed to the page after we |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
756 try to remove names from the list. |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
757 |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
758 @param pagename: name of the page to subscribe |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
759 @type pagename: unicode |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
760 @rtype: bool |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
761 @return: if unsubscrieb was successful. If the user has a |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
762 regular expression that match, it will always fail. |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
763 """ |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
764 changed = False |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
765 if pagename in self.subscribed_pages: |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
766 self.subscribed_pages.remove(pagename) |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
767 changed = True |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
768 |
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
769 interWikiName = self._interWikiName(pagename) |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
770 if interWikiName and interWikiName in self.subscribed_pages: |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
771 self.subscribed_pages.remove(interWikiName) |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
772 changed = True |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
773 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
774 if changed: |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
775 self.save() |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
776 return not self.isSubscribedTo([pagename]) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
777 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
778 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
779 # Quicklinks |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
780 |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
781 def getQuickLinks(self): |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
782 """ Get list of pages this user wants in the navibar |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
783 |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
784 @rtype: list |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
785 @return: quicklinks from user account |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
786 """ |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
787 return self.quicklinks |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
788 |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
789 def isQuickLinkedTo(self, pagelist): |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
790 """ Check if user quicklink matches any page in pagelist. |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
791 |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
792 @param pagelist: list of pages to check for quicklinks |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
793 @rtype: bool |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
794 @return: if user has quicklinked any page in pagelist |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
795 """ |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
796 if not self.valid: |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
797 return False |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
798 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
799 for pagename in pagelist: |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
800 if pagename in self.quicklinks: |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
801 return True |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
802 interWikiName = self._interWikiName(pagename) |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
803 if interWikiName and interWikiName in self.quicklinks: |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
804 return True |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
805 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
806 return False |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
807 |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
808 def addQuicklink(self, pagename): |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
809 """ Adds a page to the user quicklinks |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
810 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
811 If the wiki has an interwiki name, all links are saved as |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
812 interwiki names. If not, as simple page name. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
813 |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
814 @param pagename: page name |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
815 @type pagename: unicode |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
816 @rtype: bool |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
817 @return: if pagename was added |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
818 """ |
22
a47550d21d2d
quicklinks: avoid dupes, dont render as interwiki if wiki == self
Thomas Waldmann <tw@waldmann-edv.de>
parents:
8
diff
changeset
|
819 changed = False |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
820 interWikiName = self._interWikiName(pagename) |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
821 if interWikiName: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
822 if pagename in self.quicklinks: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
823 self.quicklinks.remove(pagename) |
22
a47550d21d2d
quicklinks: avoid dupes, dont render as interwiki if wiki == self
Thomas Waldmann <tw@waldmann-edv.de>
parents:
8
diff
changeset
|
824 changed = True |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
825 if interWikiName not in self.quicklinks: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
826 self.quicklinks.append(interWikiName) |
22
a47550d21d2d
quicklinks: avoid dupes, dont render as interwiki if wiki == self
Thomas Waldmann <tw@waldmann-edv.de>
parents:
8
diff
changeset
|
827 changed = True |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
828 else: |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
829 if pagename not in self.quicklinks: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
830 self.quicklinks.append(pagename) |
22
a47550d21d2d
quicklinks: avoid dupes, dont render as interwiki if wiki == self
Thomas Waldmann <tw@waldmann-edv.de>
parents:
8
diff
changeset
|
831 changed = True |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
832 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
833 if changed: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
834 self.save() |
22
a47550d21d2d
quicklinks: avoid dupes, dont render as interwiki if wiki == self
Thomas Waldmann <tw@waldmann-edv.de>
parents:
8
diff
changeset
|
835 return changed |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
836 |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
837 def removeQuicklink(self, pagename): |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
838 """ Remove a page from user quicklinks |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
839 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
840 Remove both interwiki and simple name from quicklinks. |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
841 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
842 @param pagename: page name |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
843 @type pagename: unicode |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
844 @rtype: bool |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
845 @return: if pagename was removed |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
846 """ |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
847 changed = False |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
848 interWikiName = self._interWikiName(pagename) |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
849 if interWikiName and interWikiName in self.quicklinks: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
850 self.quicklinks.remove(interWikiName) |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
851 changed = True |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
852 if pagename in self.quicklinks: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
853 self.quicklinks.remove(pagename) |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
854 changed = True |
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
855 |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
856 if changed: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
857 self.save() |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
858 return changed |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
859 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
860 def _interWikiName(self, pagename): |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
861 """ Return the inter wiki name of a page name |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
862 |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
863 @param pagename: page name |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
864 @type pagename: unicode |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
865 """ |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
866 if not self._cfg.interwikiname: |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
867 return None |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
868 |
88
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
869 return "%s:%s" % (self._cfg.interwikiname, pagename) |
9f037347955c
fixed quicklink bug when interwiki is None, create simpler addQuicklink and removeQuicklink methods, simplify isQuicklinkedTo method
Nir Soffer <nirs@freeshell.org>
parents:
34
diff
changeset
|
870 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
871 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
872 # Trail |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
873 |
1956
477760dd8487
speedup addTrail by passing existing page object
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1951
diff
changeset
|
874 def addTrail(self, page): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
875 """ Add page to trail. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
876 |
1956
477760dd8487
speedup addTrail by passing existing page object
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1951
diff
changeset
|
877 @param page: the page (object) to add to the trail |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
878 """ |
1935
740d9939ffe9
use session object to store page trail (even for anon users, if anon sessions are enabled)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1923
diff
changeset
|
879 if not self.valid or self.show_page_trail or self.remember_last_visit: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
880 # load trail if not known |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
881 self.getTrail() |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
882 |
1956
477760dd8487
speedup addTrail by passing existing page object
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1951
diff
changeset
|
883 pagename = page.page_name |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
884 # Add only existing pages that the user may read |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
885 if self._request: |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
886 if not (page.exists() and |
1956
477760dd8487
speedup addTrail by passing existing page object
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1951
diff
changeset
|
887 self._request.user.may.read(pagename)): |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
888 return |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
889 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
890 # Save interwiki links internally |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
891 if self._cfg.interwikiname: |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
892 pagename = self._interWikiName(pagename) |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
893 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
894 # Don't append tail to trail ;) |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
895 if self._trail and self._trail[-1] == pagename: |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
896 return |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
897 |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
898 # Append new page, limiting the length |
232
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
899 self._trail = [p for p in self._trail if p != pagename] |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
900 self._trail = self._trail[-(self._cfg.trail_size-1):] |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
901 self._trail.append(pagename) |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
902 self.saveTrail() |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
903 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
904 def saveTrail(self): |
2010
d234621dbf2f
don't store trail for first request
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
1986
diff
changeset
|
905 """ Save trail into session """ |
d234621dbf2f
don't store trail for first request
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
1986
diff
changeset
|
906 if not self._request.session.is_new: |
d234621dbf2f
don't store trail for first request
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
1986
diff
changeset
|
907 self._request.session['trail'] = self._trail |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
908 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
909 def getTrail(self): |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
910 """ Return list of recently visited pages. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
911 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
912 @rtype: list |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
913 @return: pages in trail |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
914 """ |
1935
740d9939ffe9
use session object to store page trail (even for anon users, if anon sessions are enabled)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1923
diff
changeset
|
915 if not self._trail and ( |
740d9939ffe9
use session object to store page trail (even for anon users, if anon sessions are enabled)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1923
diff
changeset
|
916 not self.valid or self.show_page_trail or self.remember_last_visit): |
740d9939ffe9
use session object to store page trail (even for anon users, if anon sessions are enabled)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1923
diff
changeset
|
917 trail = self._request.session.get('trail', []) |
232
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
918 trail = [t.strip() for t in trail] |
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
919 trail = [t for t in trail if t] |
31c1fbb101a3
remove string/Cookie import, rewrite filter/map
Thomas Waldmann <tw@waldmann-edv.de>
parents:
138
diff
changeset
|
920 self._trail = trail[-self._cfg.trail_size:] |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
921 |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
922 return self._trail |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
923 |
89
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
924 # ----------------------------------------------------------------- |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
925 # Other |
4e44f6dfdfc2
user: formatting, move related methods together
Nir Soffer <nirs@freeshell.org>
parents:
88
diff
changeset
|
926 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
927 def isCurrentUser(self): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
928 """ Check if this user object is the user doing the current request """ |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
929 return self._request.user.name == self.name |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
930 |
448
45924beef130
user.isSuperUser() check, require cfg.superuser being a list or tuple
Thomas Waldmann <tw@waldmann-edv.de>
parents:
416
diff
changeset
|
931 def isSuperUser(self): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
932 """ Check if this user is superuser """ |
1597
bbe187af4fc0
integrated MMDE (build scripts need more work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1550
diff
changeset
|
933 request = self._request |
2035
a7fb50fd67f6
user: fixed for MMDE superuser mode for logged in users only
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
2020
diff
changeset
|
934 if request.cfg.DesktopEdition and request.remote_addr == '127.0.0.1' and request.user.valid: |
1597
bbe187af4fc0
integrated MMDE (build scripts need more work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1550
diff
changeset
|
935 # the DesktopEdition gives any local user superuser powers |
bbe187af4fc0
integrated MMDE (build scripts need more work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1550
diff
changeset
|
936 return True |
bbe187af4fc0
integrated MMDE (build scripts need more work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1550
diff
changeset
|
937 superusers = request.cfg.superuser |
449
8ec16f62e989
Moved type check of the superuser setting.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
448
diff
changeset
|
938 assert isinstance(superusers, (list, tuple)) |
8ec16f62e989
Moved type check of the superuser setting.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
448
diff
changeset
|
939 return self.valid and self.name and self.name in superusers |
448
45924beef130
user.isSuperUser() check, require cfg.superuser being a list or tuple
Thomas Waldmann <tw@waldmann-edv.de>
parents:
416
diff
changeset
|
940 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
941 def host(self): |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
942 """ Return user host """ |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
943 _ = self._request.getText |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
944 host = self.isCurrentUser() and self._cfg.show_hosts and self._request.remote_addr |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
945 return host or _("<unknown>") |
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
946 |
1154
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
947 def wikiHomeLink(self): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
948 """ Return wiki markup usable as a link to the user homepage, |
1154
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
949 it doesn't matter whether it already exists or not. |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
950 """ |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
951 wikiname, pagename = wikiutil.getInterwikiHomePage(self._request, self.name) |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
952 if wikiname == 'Self': |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
953 if wikiutil.isStrictWikiname(self.name): |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
954 markup = pagename |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
955 else: |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
956 markup = '["%s"]' % pagename |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
957 else: |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
958 markup = '%s:%s' % (wikiname, pagename) # TODO: support spaces in pagename |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
959 return markup |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
960 |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
961 def signature(self): |
1154
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
962 """ Return user signature using wiki markup |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
963 |
1154
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
964 Users sign with a link to their homepage. |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
965 Visitors return their host address. |
90
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
966 |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
967 TODO: The signature use wiki format only, for example, it will |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
968 not create a link when using rst format. It will also break if |
246601c7b298
fix unsubscribe, use always valid interwiki links, more correct error messages, refactror subscribePage, isSubscribedTo
Nir Soffer <nirs@freeshell.org>
parents:
89
diff
changeset
|
969 we change wiki syntax. |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
970 """ |
1154
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
971 if self.name: |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
972 return self.wikiHomeLink() |
44632345fbfb
mailimport: use link to homepage or realname in from/to column, user.wikiHomeLink() to generate markup for user's homepage link
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1075
diff
changeset
|
973 else: |
0
77665d8e2254
tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff
changeset
|
974 return self.host() |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
975 |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
976 def mailAccountData(self, cleartext_passwd=None): |
1963
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
977 """ Mail a user who forgot his password a message enabling |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
978 him to login again. |
de42f84ddb3c
user: add some docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1957
diff
changeset
|
979 """ |
750
f158c4e8fea2
moved mail related functions to MoinMoin.mail
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
737
diff
changeset
|
980 from MoinMoin.mail import sendmail |
1784
2668d470091f
wikiutil.getSysPage renamed to getLocalizedPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1689
diff
changeset
|
981 from MoinMoin.wikiutil import getLocalizedPage |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
982 _ = self._request.getText |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
983 |
416
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
984 if not self.enc_password: # generate pw if there is none yet |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
985 from random import randint |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
986 import base64 |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
987 |
416
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
988 charset = 'utf-8' |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
989 pwd = "%s%d" % (str(time.time()), randint(0, 65535)) |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
990 pwd = pwd.encode(charset) |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
991 |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
992 pwd = sha.new(pwd).digest() |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
993 pwd = '{SHA}%s' % base64.encodestring(pwd).rstrip() |
1005
e1e1885deec1
whitespace-only cleanup, fix regex by using raw string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
826
diff
changeset
|
994 |
416
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
995 self.enc_password = pwd |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
996 self.save() |
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
997 |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
998 text = '\n' + _("""\ |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
999 Login Name: %s |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1000 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1001 Login Password: %s |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1002 |
626
50c7a0cc1791
fix forgotten password email
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
476
diff
changeset
|
1003 Login URL: %s/%s?action=login |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1004 """, formatted=False) % ( |
1784
2668d470091f
wikiutil.getSysPage renamed to getLocalizedPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
1689
diff
changeset
|
1005 self.name, self.enc_password, self._request.getBaseURL(), getLocalizedPage(self._request, 'UserPreferences').page_name) |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1006 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1007 text = _("""\ |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1008 Somebody has requested to submit your account data to this email address. |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1009 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1010 If you lost your password, please use the data below and just enter the |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1011 password AS SHOWN into the wiki's password form field (use copy and paste |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1012 for that). |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1013 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1014 After successfully logging in, it is of course a good idea to set a new and known password. |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1015 """, formatted=False) + text |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1016 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1017 |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1018 subject = _('[%(sitename)s] Your wiki account data', |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1019 formatted=False) % {'sitename': self._cfg.sitename or "Wiki"} |
750
f158c4e8fea2
moved mail related functions to MoinMoin.mail
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
737
diff
changeset
|
1020 mailok, msg = sendmail.sendmail(self._request, [self.email], subject, |
138
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1021 text, mail_from=self._cfg.mail_from) |
81654a482b3a
Added createonly parameter to UserPreferences macro and userform action; moved mailAccountData to the user object; extended SystemAdmin to offer 'send acount data' links; fixed minor quoting problem in Page.link_to()
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents:
121
diff
changeset
|
1022 return msg |
416
fb5e1ecdbc33
generate rnd password when there is none yet
Thomas Waldmann <tw@waldmann-edv.de>
parents:
339
diff
changeset
|
1023 |