annotate MoinMoin/xmlrpc/__init__.py @ 3049:ed9b1e5cf0e1

fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Feb 2008 23:21:58 +0100
parents 06547d7df727
children 2a3a6cb34e45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 """
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
3 MoinMoin - Wiki XMLRPC v1 and v2 Interface + plugin extensions
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1977
abcbc20e8f8f raise unzip_attachments_count to 101, some other minor changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1960
diff changeset
5 Parts of this code are based on Juergen Hermann's wikirpc.py,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 Les Orchard's "xmlrpc.cgi" and further work by Gustavo Niemeyer.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9 and http://www.decafbad.com/twiki/bin/view/Main/XmlRpcToWiki
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10 for specs on many of the functions here.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 See also http://www.jspwiki.org/Wiki.jsp?page=WikiRPCInterface2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 for the new stuff.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 The main difference between v1 and v2 is that v2 relies on utf-8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 as transport encoding. No url-encoding and no base64 anymore, except
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 when really necessary (like for transferring binary files like
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 attachments maybe).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
20 @copyright: 2003-2007 MoinMoin:ThomasWaldmann,
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1804
diff changeset
21 2004-2006 MoinMoin:AlexanderSchremmer
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 @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
23 """
637
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
24 from MoinMoin.util import pysupport
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
25
35f0f8584a57 move wikirpc.py to xmlrpc/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 622
diff changeset
26 modules = pysupport.getPackageModules(__file__)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
28 import os, sys, time, xmlrpclib
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 from MoinMoin import config, user, wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 from MoinMoin.PageEditor import PageEditor
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33 from MoinMoin.logfile import editlog
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
34 from MoinMoin.action import AttachFile
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
35 from MoinMoin import caching
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
36 from MoinMoin import session
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 _debug = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
40
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
41 class XmlRpcAuthTokenIDHandler(session.SessionIDHandler):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
42 def __init__(self, token=None):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
43 session.SessionIDHandler.__init__(self)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
44 self.token = token
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
45
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
46 def get(self, request):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
47 return self.token
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
48
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
49 def set(self, request, session_id, expires):
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
50 self.token = session_id
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
51
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
52
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 class XmlRpcBase:
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
54 """ XMLRPC base class with common functionality of wiki xmlrpc v1 and v2 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 Initialize an XmlRpcBase object.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 @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
59 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 self.request = request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 self.version = None # this has to be defined in derived class
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62 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
63
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
64 #############################################################################
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
65 ### Helper functions
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 def _instr(self, text):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
69 """ Convert inbound string.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
70
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
71 @param text: the text to convert (encoded str or unicode)
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
72 @rtype: unicode
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
73 @return: text as unicode
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
75 raise NotImplementedError("please implement _instr in derived class")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
76
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 def _outstr(self, text):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
78 """ Convert outbound string.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
80 @param text: the text to convert (encoded str or unicode)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 @rtype: str
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
82 @return: text as encoded str
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 """
1072
c1f5ee67a02b use exception class instead of string
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
84 raise NotImplementedError("please implement _outstr in derived class")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
85
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 def _inlob(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 """ Convert inbound base64-encoded utf-8 to Large OBject.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
88
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
89 @param text: the text to convert
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
91 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
93 text = text.data #this is a already base64-decoded 8bit string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
94 text = unicode(text, 'utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
95 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
96
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97 def _outlob(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98 """ Convert outbound Large OBject to base64-encoded utf-8.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
99
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
100 @param text: the text, either unicode or utf-8 string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
101 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102 @return: xmlrpc Binary object
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
103 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
104 if isinstance(text, unicode):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105 text = text.encode('utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
107 if config.charset != 'utf-8':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 text = unicode(text, config.charset).encode('utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
109 return xmlrpclib.Binary(text)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
110
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
111 def _dump_exc(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 """ Convert an exception to a string.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
113
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 @return: traceback as string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 import traceback
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 return "%s: %s\n%s" % (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
120 sys.exc_info()[0],
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121 sys.exc_info()[1],
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 '\n'.join(traceback.format_tb(sys.exc_info()[2])),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
123 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
125 def process(self):
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
126 """ xmlrpc v1 and v2 dispatcher """
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
127 try:
2799
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
128 if 'xmlrpc' in self.request.cfg.actions_excluded:
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
129 # we do not handle xmlrpc v1 and v2 differently
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
130 response = xmlrpclib.Fault(1, "This moin wiki does not allow xmlrpc method calls.")
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
131 else:
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
132 data = self.request.read()
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
133 params, method = xmlrpclib.loads(data)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
134
2799
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
135 if _debug:
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
136 sys.stderr.write('- XMLRPC ' + '-' * 70 + '\n')
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
137 sys.stderr.write('%s(%s)\n\n' % (method, repr(params)))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
138
2799
eab2cd188ca6 added 'xmlrpc' to actions_excluded default value, return Fault if xmlrpc action is excluded
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2795
diff changeset
139 response = self.dispatch(method, params)
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
140 except:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
141 # report exception back to server
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
142 response = xmlrpclib.dumps(xmlrpclib.Fault(1, self._dump_exc()))
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
143 else:
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
144 if isinstance(response, xmlrpclib.Fault):
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
145 response = xmlrpclib.dumps(response)
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
146 else:
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
147 # wrap response in a singleton tuple
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
148 response = (response, )
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
149
1160
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
150 # serialize it
3c80692b9b47 Added support for XMLRPC functions that return a Fault instance.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1139
diff changeset
151 response = xmlrpclib.dumps(response, methodresponse=1)
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
152
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1053
diff changeset
153 self.request.emit_http_headers([
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1053
diff changeset
154 "Content-Type: text/xml; charset=utf-8",
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
155 "Content-Length: %d" % len(response),
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
156 ])
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
157 self.request.write(response)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
158
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
159 if _debug:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
160 sys.stderr.write('- XMLRPC ' + '-' * 70 + '\n')
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
161 sys.stderr.write(response + '\n\n')
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
162
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
163 def dispatch(self, method, params):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
164 """ call dispatcher - for method==xxx it either locates a method called
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
165 xmlrpc_xxx or loads a plugin from plugin/xmlrpc/xxx.py
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
166 """
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
167 method = method.replace(".", "_")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
168
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
169 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
170 fn = getattr(self, 'xmlrpc_' + method)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
171 except AttributeError:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
172 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
173 fn = wikiutil.importPlugin(self.request.cfg, 'xmlrpc',
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
174 method, 'execute')
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
175 except wikiutil.PluginMissingError:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
176 response = xmlrpclib.Fault(1, "No such method: %s." %
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
177 method)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
178 else:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
179 response = fn(self, *params)
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
180 else:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
181 response = fn(*params)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
182
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
183 return response
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
184
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
185 # Common faults -----------------------------------------------------
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
186
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
187 def notAllowedFault(self):
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
188 return xmlrpclib.Fault(1, "You are not allowed to read this page.")
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
189
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
190 def noSuchPageFault(self):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
191 return xmlrpclib.Fault(1, "No such page was found.")
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
192
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
193 #############################################################################
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
194 ### System methods
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
195 #############################################################################
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
196
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
197 def xmlrpc_system_multicall(self, call_list):
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
198 """system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => [[4], ...]
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
199
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
200 Allows the caller to package multiple XML-RPC calls into a single
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
201 request.
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
202
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
203 See http://www.xmlrpc.com/discuss/msgReader$1208
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
204
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
205 Copied from SimpleXMLRPCServer.py
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
206 """
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
207
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
208 results = []
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
209 for call in call_list:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
210 method_name = call['methodName']
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
211 params = call['params']
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
212
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
213 try:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
214 # XXX A marshalling error in any response will fail the entire
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
215 # multicall. If someone cares they should fix this.
2126
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
216 result = self.dispatch(method_name, params)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
217
2126
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
218 if not isinstance(result, xmlrpclib.Fault):
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
219 results.append([result])
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
220 else:
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
221 results.append(
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
222 {'faultCode': result.faultCode,
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
223 'faultString': result.faultString}
8b7d6d70fc95 Fix reporting of faults in xmlrpc multicall code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2122
diff changeset
224 )
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
225 except:
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
226 results.append(
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
227 {'faultCode': 1,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
228 'faultString': "%s:%s" % (sys.exc_type, sys.exc_value)}
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
229 )
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
230
781
e46109ce944e Introduced multicall support. Refactored XmlRpcBase (moved methods, separated dispatcher). Added Python 2.3 support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
231 return results
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
232
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
233 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
234 ### Interface implementation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
235 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
236
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
237 def xmlrpc_getRPCVersionSupported(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
238 """ Returns version of the Wiki API.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
240 @rtype: int
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
241 @return: 1 or 2 (wikirpc version)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
242 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
243 return self.version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
244
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
245 def xmlrpc_getAllPages(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
246 """ Get all pages readable by current user
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
247
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
248 @rtype: list
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
249 @return: a list of all pages.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250 """
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
251
1040
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
252 # the official WikiRPC interface is implemented by the extended method
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
253 # as well
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
254 return self.xmlrpc_getAllPagesEx()
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
255
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
256
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
257 def xmlrpc_getAllPagesEx(self, opts=None):
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
258 """ Get all pages readable by current user. Not an WikiRPC method.
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
259
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
260 @param opts: dictionary that can contain the following arguments:
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
261 include_system:: set it to false if you do not want to see system pages
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
262 include_revno:: set it to True if you want to have lists with [pagename, revno]
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
263 include_deleted:: set it to True if you want to include deleted pages
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
264 exclude_non_writable:: do not include pages that the current user may not write to
1262
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
265 include_underlay:: return underlay pagenames as well
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
266 prefix:: the page name must begin with this prefix to be included
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
267 mark_deleted:: returns the revision number -rev_no if the page was deleted.
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
268 Makes only sense if you enable include_revno and include_deleted.
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
269 @rtype: list
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
270 @return: a list of all pages.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
271 """
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
272 from MoinMoin.wikisync import normalise_pagename
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
273 options = {"include_system": True, "include_revno": False, "include_deleted": False,
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
274 "exclude_non_writable": False, "include_underlay": True, "prefix": "",
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
275 "pagelist": None, "mark_deleted": False}
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
276 if opts is not None:
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
277 options.update(opts)
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
278
1040
ad101845642b Call the Ex method from the original method, fixed a bug in the Ex method (wikirpc)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1035
diff changeset
279 if not options["include_system"]:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
280 p_filter = lambda name: not wikiutil.isSystemPage(self.request, name)
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
281 else:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
282 p_filter = lambda name: True
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
283
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
284 if options["exclude_non_writable"]:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
285 p_filter = lambda name, p_filter=p_filter: p_filter(name) and self.request.user.may.write(name)
1161
84ca2d77b8e4 Added support for "exclude_non_writable" in getAllPagesEx.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1160
diff changeset
286
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
287 if options["prefix"] or options["pagelist"]:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
288 def p_filter(name, p_filter=p_filter, prefix=(options["prefix"] or ""), pagelist=options["pagelist"]):
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
289 if not p_filter(name):
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
290 return False
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
291 n_name = normalise_pagename(name, prefix)
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
292 if not n_name:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
293 return False
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
294 if not pagelist:
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
295 return True
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
296 return n_name in pagelist
1262
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
297
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
298 pagelist = self.request.rootpage.getPageList(filter=p_filter, exists=not options["include_deleted"],
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
299 include_underlay=options["include_underlay"],
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
300 return_objects=options["include_revno"])
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
301
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
302 if options['include_revno']:
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
303 pages = []
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
304 for page in pagelist:
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
305 revno = page.get_real_rev()
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
306 if options["mark_deleted"] and not page.exists():
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
307 revno = -revno
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
308 pages.append([self._outstr(page.page_name), revno])
1315
ed3baf538cd5 Added infrastructure support for deleted pages in the sync framework.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
309 return pages
1029
14d12dfdcd4c Added new XMLRPC getAllPagesEx method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1024
diff changeset
310 else:
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
311 return [self._outstr(page) for 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
312
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
313 def xmlrpc_getRecentChanges(self, date):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
314 """ Get RecentChanges since date
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
315
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
316 @param date: date since when rc will be listed
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
317 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
318 @return: a list of changed pages since date, which should be in
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
319 UTC. The result is a list, where each element is a struct:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
320 * name (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
321 Name of the page. The name is in UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
322 * lastModified (date) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
323 Date of last modification, in UTC.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
324 * author (string) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
325 Name of the author (if available). UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
326 * version (int) :
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
327 Current version.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 """
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
329
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
330 return_items = []
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
331
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
332 edit_log = editlog.EditLog(self.request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
333 for log in edit_log.reverse():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
334 # get last-modified UTC (DateTime) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
335 gmtuple = tuple(time.gmtime(wikiutil.version2timestamp(log.ed_time_usecs)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
336 lastModified_date = xmlrpclib.DateTime(gmtuple)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
337
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 # skip if older than "date"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
339 if lastModified_date < date:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
340 break
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
341
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 # skip if knowledge not permitted
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 if not self.request.user.may.read(log.pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
344 continue
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
345
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
346 # get page name (str) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 pagename_str = self._outstr(log.pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 # get user name (str) from log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350 author_str = log.hostname
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 if log.userid:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 userdata = user.User(self.request, log.userid)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 if userdata.name:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 author_str = userdata.name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
355 author_str = self._outstr(author_str)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
356
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
357 return_item = {'name': pagename_str,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
358 'lastModified': lastModified_date,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
359 'author': author_str,
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
360 'version': int(log.rev) }
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
361 return_items.append(return_item)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
362
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
363 return return_items
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365 def xmlrpc_getPageInfo(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
366 """ Invoke xmlrpc_getPageInfoVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 return self.xmlrpc_getPageInfoVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369 def xmlrpc_getPageInfoVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 """ Return page information for specific revision
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
371
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
372 @param pagename: the name of the page (utf-8)
1799
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
373 @param rev: revision to get info about (int)
06ce4843b9b5 remove some XXX strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
374 @rtype: dict
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375 @return: page information
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
376 * name (string): the canonical page name, UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
377 * lastModified (date): Last modification date, UTC.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
378 * author (string): author name, UTF-8.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
379 * version (int): current version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
380
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 pn = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
383
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 # User may read this page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
385 if not self.request.user.may.read(pn):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
386 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
387
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
388 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
389 page = Page(self.request, pn, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
390 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391 page = Page(self.request, pn)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392 rev = page.current_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
393
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
394 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
395 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
397
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398 # Get page info
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
399 last_edit = page.last_edit(self.request)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 mtime = wikiutil.version2timestamp(long(last_edit['timestamp'])) # must be long for py 2.2.x
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 gmtuple = tuple(time.gmtime(mtime))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
402
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403 version = rev # our new rev numbers: 1,2,3,4,....
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405 #######################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
406 # BACKWARDS COMPATIBILITY CODE - remove when 1.2.x is regarded stone age
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
407 # as we run a feed for BadContent on MoinMaster, we want to stay
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
408 # compatible here for a while with 1.2.x moins asking us for BadContent
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
409 # 1.3 uses the lastModified field for checking for updates, so it
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410 # should be no problem putting the old UNIX timestamp style of version
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411 # number in the version field
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
412 if self.request.cfg.sitename == 'MoinMaster' and pagename == 'BadContent':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
413 version = int(mtime)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 #######################################################################
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
415
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
416 return {
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417 'name': self._outstr(page.page_name),
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
418 'lastModified': xmlrpclib.DateTime(gmtuple),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 'author': self._outstr(last_edit['editor']),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420 'version': version,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
421 }
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
422
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
423 def xmlrpc_getPage(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
424 """ Invoke xmlrpc_getPageVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
425 return self.xmlrpc_getPageVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
426
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
427 def xmlrpc_getPageVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 """ Get raw text from specific revision of pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
429
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 @param pagename: pagename (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
431 @param rev: revision number (int)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
432 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
433 @return: utf-8 encoded page data
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
434 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
436
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
437 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
438 if not self.request.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
439 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
440
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
441 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
442 page = Page(self.request, pagename, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
443 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 page = Page(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
445
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
446 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
447 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
448 return self.noSuchPageFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
449
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
450 # Return page raw text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
451 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
452 return self._outstr(page.get_raw_body())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
453 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
454 return self._outlob(page.get_raw_body())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
455
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
456 def xmlrpc_getPageHTML(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
457 """ Invoke xmlrpc_getPageHTMLVersion with rev=None """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
458 return self.xmlrpc_getPageHTMLVersion(pagename, rev=None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
459
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
460 def xmlrpc_getPageHTMLVersion(self, pagename, rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
461 """ Get HTML of from specific revision of pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
462
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
463 @param pagename: the page name (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
464 @param rev: revision number (int)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
465 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
466 @return: page in rendered HTML (utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
467 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
468 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
469
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
470 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
471 if not self.request.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
472 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
473
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
474 if rev is not None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
475 page = Page(self.request, pagename, rev=rev)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
476 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
477 page = Page(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
478
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
479 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
480 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
481 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
482
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
483 # Render page into a buffer
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1385
diff changeset
484 result = self.request.redirectedOutput(page.send_page, content_only=1)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
485
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
486 # Return rendered page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
487 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
488 return self._outstr(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
489 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
490 return xmlrpclib.Binary(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
491
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
492 def xmlrpc_listLinks(self, pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
493 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
494 list links for a given page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
495 @param pagename: the page name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
496 @rtype: list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
497 @return: links of the page, structs, with the following elements
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
498 * name (string) : The page name or URL the link is to, UTF-8 encoding.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
499 * type (int) : The link type. Zero (0) for internal Wiki
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
500 link, one (1) for external link (URL - image link, whatever).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
501 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
502 pagename = self._instr(pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
503
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
504 # User may read page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
505 if not self.request.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
506 return self.notAllowedFault()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
507
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
508 page = Page(self.request, pagename)
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 # Non existing page?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
511 if not page.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
512 return self.noSuchPageFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
513
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
514 links_out = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
515 for link in page.getPageLinks(self.request):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
516 links_out.append({'name': self._outstr(link), 'type': 0 })
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
517 return links_out
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
518
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
519 def xmlrpc_putPage(self, pagename, pagetext):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
520 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
521 save a page / change a page to a new text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
522 @param pagename: the page name (unicode or utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
523 @param pagetext: the new page text (content, unicode or utf-8)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
524 @rtype: bool
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
525 @return: true on success
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
526 """
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
527
2795
f24afde03048 xmlrpc_putPage: call depends on acls and wiki auth or http auth, identical to wikisync, wiki auth see following example
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2698
diff changeset
528 pagename = self._instr(pagename)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
529
3049
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
530 if not pagename:
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
531 return xmlrpclib.Fault("INVALID", "pagename can't be empty")
ed9b1e5cf0e1 fix MoinMoinBugs/XmlRpcPutPageAllowsEmptyPageName (thanks to Jonas Wagner) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2916
diff changeset
532
2916
06547d7df727 fix putPage comment
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2915
diff changeset
533 # check ACLs
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
534 if not self.request.user.may.write(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
535 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
536
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
537 page = PageEditor(self.request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
538 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
539 if self.version == 2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
540 newtext = self._instr(pagetext)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
541 elif self.version == 1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
542 newtext = self._inlob(pagetext)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
543 msg = page.saveText(newtext, 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
544 except page.SaveError, msg:
2915
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
545 if _debug:
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
546 sys.stderr.write("Msg: %s\n" % msg)
05d90815b0f9 xmlrpc: fault on save errors
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2914
diff changeset
547 return xmlrpclib.Fault(1, "%s" % msg)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
548
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
549 # Update pagelinks cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
550 page.getPageLinks(self.request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
551
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
552 return xmlrpclib.Boolean(1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
553
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
554 def xmlrpc_revertPage(self, pagename, revision):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
555 """Revert a page to previous revision
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
556
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
557 This is mainly intended to be used by the jabber bot.
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
558
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
559 @param pagename: the page name (unicode or utf-8)
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
560 @param revision: revision to revert to
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
561 @rtype bool
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
562 @return true on success
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
563
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
564 """
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
565 if not self.request.user.may.write(pagename):
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
566 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
567
2698
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
568 from MoinMoin.PageEditor import PageEditor
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
569 rev = int(self._instr(revision))
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
570 editor = PageEditor(self.request, pagename)
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
571
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
572 try:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
573 editor.revertPage(rev)
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
574 except PageEditor.SaveError, error:
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
575 return xmlrpclib.Fault(1, "Revert failed: %s" % (str(error), ))
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
576
0a6f74a01646 Fix revert action and xmlrpc call.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2675
diff changeset
577 return xmlrpclib.Boolean(1)
2671
9bc7d2c14e1f Add suport for reverting pages (text-only for now).
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2657
diff changeset
578
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
579 def xmlrpc_searchPages(self, query_string):
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
580 """ Searches pages for query_string.
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
581 Returns a list of tuples (foundpagename, context)
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
582 """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
583 from MoinMoin import search
919
5469c8b911a4 Splitting out MoinMoin/search.py to MoinMoin/search/*.py
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 787
diff changeset
584 results = search.searchPages(self.request, query_string)
622
8fba6d15a2f5 make request.(html_)formatter available early and use it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 101
diff changeset
585 results.formatter = self.request.html_formatter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
586 results.request = self.request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
587 return [(self._outstr(hit.page_name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
588 self._outstr(results.formatContext(hit, 180, 1)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
589 for hit in results.hits]
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
590
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
591 def xmlrpc_searchPagesEx(self, query_string, search_type, length, case, mtime, regexp):
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
592 """ Searches pages for query_string - extended version for compatibility
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
593
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
594 This function, in contrary to searchPages(), doesn't return HTML-formatted data.
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
595
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
596 @param query_string: term to search for
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
597 @param search_type: "text" or "title" search
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
598 @param length: length of context preview (in characters)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
599 @param case: should the search be case sensitive?
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
600 @param mtime: only output pages modified after mtime
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
601 @param regexp: should the query_string be treates as a regular expression?
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
602 @return: (page name, context preview, page url)
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
603
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
604 """
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
605 from MoinMoin import search
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
606 from MoinMoin.formatter.text_plain import Formatter
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
607
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
608 kwargs = {"sort": "page_name", "case": case, "regex": regexp}
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
609 if search_type == "title":
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
610 kwargs["titlesearch"] = True
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
611
2649
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
612 results = search.searchPages(self.request, query_string, **kwargs)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
613 results.formatter = Formatter(self.request)
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
614 results.request = self.request
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
615
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
616 return [(self._outstr(hit.page_name),
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
617 self._outstr(results.formatContext(hit, length, 1)),
3878ffc317da xmlrpc_searchPagesEx() with more options and no html formatting of output.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2587
diff changeset
618 self.request.getQualifiedURL(hit.page.url(self.request, {}, relative=False)))
2657
d3503c3c2ba4 More whitespace fixes.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2649
diff changeset
619 for hit in results.hits]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
620
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
621 def xmlrpc_getMoinVersion(self):
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
622 """ Returns a tuple of the MoinMoin version:
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
623 (project, release, revision)
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
624 """
782
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
625 from MoinMoin import version
c4c66a5a2221 Added xmlrpc method to return the MoinMoin version.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 781
diff changeset
626 return (version.project, version.release, version.revision)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
627
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
628
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
629 # user profile data transfer
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
630
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
631 def xmlrpc_getUserProfile(self):
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
632 """ Return the user profile data for the current user.
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
633 Use this in a single multicall after applyAuthToken.
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
634 If we have a valid user, returns a dict of items from user profile.
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
635 Otherwise, return an empty dict.
1960
1687a0130ebe xmlrpc: cleanup/add docstrings, minor refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1951
diff changeset
636 """
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
637 u = self.request.user
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
638 if not u.valid:
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
639 userdata = {}
1951
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
640 else:
a05a3b447db5 interwiki auth fixed, added getUserData xmlrpc method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
641 userdata = dict(u.persistent_items())
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
642 return userdata
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
643
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
644 def xmlrpc_getUserLanguageByJID(self, jid):
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
645 """ Returns user's language given his/her Jabber ID
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
646
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
647 It makes no sense to consider this a secret, right? Therefore
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
648 an authentication token is not required. We return a default
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
649 of "en" if user is not found.
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
650
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
651 TODO: surge protection? Do we fear account enumeration?
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
652 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
653 retval = "en"
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
654 u = user.get_by_jabber_id(self.request, jid)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
655 if u:
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
656 retval = u.language
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
657
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
658 return retval
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
659
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
660 # authorization methods
2181
340ae0e7529e replace xmlrpc getUser by getUserProfile, auth can be done by getAuthToken/applyAuthToken in the same multicall, use for interwiki auth
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2126
diff changeset
661
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
662 def xmlrpc_getAuthToken(self, username, password, *args):
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
663 """ Returns a token which can be used for authentication
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
664 in other XMLRPC calls. If the token is empty, the username
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
665 or the password were wrong.
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
666 """
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
667 id_handler = XmlRpcAuthTokenIDHandler()
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
668
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
669 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
670 u = self.request.handle_auth(u, username=username,
2009
1b14cc05a54a refactor authentication and split out session handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1977
diff changeset
671 password=password, login=True)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
672
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
673 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
674
2009
1b14cc05a54a refactor authentication and split out session handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1977
diff changeset
675 if u and u.valid:
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
676 return id_handler.token
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
677 else:
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
678 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
679
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
680 def xmlrpc_getJabberAuthToken(self, jid, secret):
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
681 """Returns a token which can be used for authentication.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
682
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
683 This token can be used in other XMLRPC calls. Generation of
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
684 token depends on user's JID and a secret shared between wiki
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
685 and Jabber bot.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
686
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
687 @param jid: a bare Jabber ID
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
688 """
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
689 if self.cfg.secret != secret:
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
690 return ""
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
691
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
692 u = self.request.handle_jid_auth(jid)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
693
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
694 if u and u.valid:
2499
b5a711a9ec09 Fix generation of auth tokens in xmlrpc code.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2472
diff changeset
695 return self._generate_auth_token(u)
2122
69412724ce93 Make it possible to get an auth token using jid and shared secret.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2119
diff changeset
696 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
697 return ""
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
698
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
699 def xmlrpc_applyAuthToken(self, auth_token):
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
700 """ Applies the auth token and thereby authenticates the user. """
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
701 id_handler = XmlRpcAuthTokenIDHandler(auth_token)
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
702
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
703 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
704 u = self.request.handle_auth(u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
705 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
706 if u and u.valid:
956
413263beeafc Changed auth token api to authenticate only (no calls because it would not work with MultiCall otherwise
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 955
diff changeset
707 return "SUCCESS"
955
05b7c435a3d6 Implemented token functions that use the normal moin id
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 954
diff changeset
708 else:
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
709 return xmlrpclib.Fault("INVALID", "Invalid token.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
710
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
711
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
712 def xmlrpc_deleteAuthToken(self, auth_token):
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
713 """ Delete the given auth token. """
2914
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
714 id_handler = XmlRpcAuthTokenIDHandler(auth_token)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
715
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
716 u = self.request.cfg.session_handler.start(self.request, id_handler)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
717 u = self.request.handle_auth(u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
718 self.request.cfg.session_handler.after_auth(self.request, id_handler, u)
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
719
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
720 self.request.session.delete()
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
721
25ee42ee758a tie xmlrpc into regular session/auth
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2799
diff changeset
722 return "SUCCESS"
2032
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
723
cf883a6917ea better xmlrpc auth token handling
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2020
diff changeset
724
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
725 # methods for wiki synchronization
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
726
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
727 def xmlrpc_getDiff(self, pagename, from_rev, to_rev, n_name=None):
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
728 """ Gets the binary difference between two page revisions.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
729
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
730 @param pagename: unicode string qualifying the page name
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
731
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
732 @param fromRev: integer specifying the source revision. May be None to
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
733 refer to a virtual empty revision which leads to a diff
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
734 containing the whole page.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
735
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
736 @param toRev: integer specifying the target revision. May be None to
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
737 refer to the current revision. If the current revision is the same
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
738 as fromRev, there will be a special error condition "ALREADY_CURRENT"
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
739
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
740 @param n_name: do a tag check verifying that n_name was the normalised
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
741 name of the last tag
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
742
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
743 If both fromRev and toRev are None, this function acts similar to getPage, i.e. it will diff("",currentRev).
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
744
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
745 @return Returns a dict:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
746 * status (not a field, implicit, returned as Fault if not SUCCESS):
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
747 * "SUCCESS" - if the diff could be retrieved successfully
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
748 * "NOT_EXIST" - item does not exist
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
749 * "FROMREV_INVALID" - the source revision is invalid
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
750 * "TOREV_INVALID" - the target revision is invalid
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
751 * "INTERNAL_ERROR" - there was an internal error
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
752 * "INVALID_TAG" - the last tag does not match the supplied normalised name
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
753 * "ALREADY_CURRENT" - this not merely an error condition. It rather means that
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
754 there is no new revision to diff against which is a good thing while
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
755 synchronisation.
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
756 * current: the revision number of the current revision (not the one which was diff'ed against)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
757 * diff: Binary object that transports a zlib-compressed binary diff (see bdiff.py, taken from Mercurial)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
758 * conflict: if there is a conflict on the page currently
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
759
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
760 """
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
761 from MoinMoin.util.bdiff import textdiff, compress
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
762 from MoinMoin.wikisync import TagStore
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
763
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
764 pagename = self._instr(pagename)
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
765 if n_name is not None:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
766 n_name = self._instr(n_name)
787
9d74a2f53323 Merge with main.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 786 758
diff changeset
767
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
768 # User may read page?
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
769 if not self.request.user.may.read(pagename):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
770 return self.notAllowedFault()
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
771
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
772 def allowed_rev_type(data):
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
773 if data is None:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
774 return True
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
775 return isinstance(data, int) and data > 0
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
776
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
777 if not allowed_rev_type(from_rev):
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
778 return xmlrpclib.Fault("FROMREV_INVALID", "Incorrect type for from_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
779
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
780 if not allowed_rev_type(to_rev):
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
781 return xmlrpclib.Fault("TOREV_INVALID", "Incorrect type for to_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
782
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
783 currentpage = Page(self.request, pagename)
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
784 if not currentpage.exists():
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
785 return xmlrpclib.Fault("NOT_EXIST", "Page does not exist.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
786
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
787 revisions = currentpage.getRevList()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
788
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
789 if from_rev is not None and from_rev not in revisions:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
790 return xmlrpclib.Fault("FROMREV_INVALID", "Unknown from_rev.")
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
791 if to_rev is not None and to_rev not in revisions:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
792 return xmlrpclib.Fault("TOREV_INVALID", "Unknown to_rev.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
793
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
794 # use lambda to defer execution in the next lines
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
795 if from_rev is None:
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
796 oldcontents = lambda: ""
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
797 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
798 oldpage = Page(self.request, pagename, rev=from_rev)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
799 oldcontents = lambda: oldpage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
800
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
801 if to_rev is None:
1250
97e9866e82c7 Fixed minor bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1161
diff changeset
802 newpage = currentpage
1256
f3c8f750c1fe Another minor unicode bug in getDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1255
diff changeset
803 newcontents = lambda: currentpage.get_raw_body_str()
969
2ec25306c4a0 Added getDiff XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 967
diff changeset
804 else:
1074
40b708ecc332 Fixed minor bug in XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
805 newpage = Page(self.request, pagename, rev=to_rev)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
806 newcontents = lambda: newpage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
807
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
808 if oldcontents() and oldpage.get_real_rev() == newpage.get_real_rev():
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
809 return xmlrpclib.Fault("ALREADY_CURRENT", "There are no changes.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
810
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
811 if n_name is not None:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
812 tags = TagStore(newpage)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
813 last_tag = tags.get_last_tag()
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
814 if last_tag is not None and last_tag.normalised_name != n_name:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
815 return xmlrpclib.Fault("INVALID_TAG", "The used tag is incorrect because the normalised name does not match.")
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
816
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
817 newcontents = newcontents()
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
818 conflict = wikiutil.containsConflictMarker(newcontents)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
819 diffblob = xmlrpclib.Binary(compress(textdiff(oldcontents(), newcontents)))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
820
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 969
diff changeset
821 return {"conflict": conflict, "diff": diffblob, "diffversion": 1, "current": currentpage.get_real_rev()}
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
822
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
823 def xmlrpc_interwikiName(self):
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
824 """ Returns the interwiki name and the IWID of the current wiki. """
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
825 name = self.request.cfg.interwikiname
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
826 iwid = self.request.cfg.iwid
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
827 if name is None:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
828 return [None, iwid]
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
829 else:
1053
6632f9919a89 Implemented IWID system.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1048
diff changeset
830 return [self._outstr(name), iwid]
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
831
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1269
diff changeset
832 def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
833 """ Merges a diff sent by the remote machine and returns the number of the new revision.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
834 Additionally, this method tags the new revision.
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
835
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
836 @param pagename: The pagename that is currently dealt with.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
837 @param diff: The diff that can be applied to the version specified by delta_remote_rev.
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
838 If it is None, the page is deleted.
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
839 @param local_rev: The revno of the page on the other wiki system, used for the tag.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
840 @param delta_remote_rev: The revno that the diff is taken against.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
841 @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
842 @param interwiki_name: Used to build the interwiki tag.
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1269
diff changeset
843 @param normalised_name: The normalised pagename that is common to both wikis.
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
844
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
845 @return Returns the current revision number after the merge was done. Or one of the following errors:
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
846 * "SUCCESS" - the page could be merged and tagged successfully.
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
847 * "NOT_EXIST" - item does not exist and there was not any content supplied.
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
848 * "LASTREV_INVALID" - the page was changed and the revision got invalid
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
849 * "INTERNAL_ERROR" - there was an internal error
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
850 * "NOT_ALLOWED" - you are not allowed to do the merge operation on the page
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
851 """
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
852 from MoinMoin.util.bdiff import decompress, patch
1269
151da160dcea Moved an import in the XMLRPC code.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
853 from MoinMoin.wikisync import TagStore, BOTH
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1315
diff changeset
854 from MoinMoin.packages import unpackLine
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
855 LASTREV_INVALID = xmlrpclib.Fault("LASTREV_INVALID", "The page was changed")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
856
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
857 pagename = self._instr(pagename)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
858
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1315
diff changeset
859 comment = u"Remote Merge - %r" % unpackLine(interwiki_name)[-1]
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
860
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
861 # User may read page?
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
862 if not self.request.user.may.read(pagename) or not self.request.user.may.write(pagename):
1385
8bf6e48c6236 Added rollback and exception logging to SyncPages.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1351
diff changeset
863 return xmlrpclib.Fault("NOT_ALLOWED", "You are not allowed to write to this page.")
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
864
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
865 # XXX add locking here!
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
866
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
867 # current version of the page
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
868 currentpage = PageEditor(self.request, pagename, do_editor_backup=0)
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
869
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
870 if last_remote_rev is not None and currentpage.get_real_rev() != last_remote_rev:
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
871 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
872
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
873 if not currentpage.exists() and diff is None:
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
874 return xmlrpclib.Fault("NOT_EXIST", "The page does not exist and no diff was supplied.")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
875
1343
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
876 if diff is None: # delete the page
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
877 try:
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
878 currentpage.deletePage(comment)
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
879 except PageEditor.AccessDenied, (msg, ):
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
880 return xmlrpclib.Fault("NOT_ALLOWED", msg)
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
881 return currentpage.get_real_rev()
144c3281e88f Now the deletion of remote pages is working.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1327
diff changeset
882
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
883 # base revision used for the diff
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
884 basepage = Page(self.request, pagename, rev=(delta_remote_rev or 0))
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
885
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
886 # generate the new page revision by applying the diff
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
887 newcontents = patch(basepage.get_raw_body_str(), decompress(str(diff)))
1260
5d555ec6b40a Fixed a bug that was hard to track down in SyncPages (some hours spent :-/).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1257
diff changeset
888 #print "Diff against %r" % basepage.get_raw_body_str()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
889
973
49a9baa51a1f Fixed getDiff, added interwikiName, mergeContents (preliminary). Added entries to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
890 # write page
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
891 try:
1325
c48e57b1460a Allow passing None for some rev parameters of mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
892 currentpage.saveText(newcontents.decode("utf-8"), last_remote_rev or 0, comment=comment)
1257
5b015ced5609 Fixed a corner case where both wiki's pages are equal.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1256
diff changeset
893 except PageEditor.Unchanged: # could happen in case of both wiki's pages being equal
5b015ced5609 Fixed a corner case where both wiki's pages are equal.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1256
diff changeset
894 pass
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
895 except PageEditor.EditConflict:
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
896 return LASTREV_INVALID
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
897
1024
608fbab8b6c3 Fixed typos.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1020
diff changeset
898 current_rev = currentpage.get_real_rev()
1344
564cc2b53ea9 Reworded a docstring in SyncPages.sync, whitespace cleanup.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1343
diff changeset
899
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
900 tags = TagStore(currentpage)
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1269
diff changeset
901 tags.add(remote_wiki=interwiki_name, remote_rev=local_rev, current_rev=current_rev, direction=BOTH, normalised_name=normalised_name)
1020
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
902
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
903 # XXX unlock page
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
904
86f141856d2b Finished first version of the mergeChanges method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 974
diff changeset
905 return current_rev
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
906
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
907
758
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
908 # XXX BEGIN WARNING XXX
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
909 # All xmlrpc_*Attachment* functions have to be considered as UNSTABLE API -
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
910 # they are neither standard nor are they what we need when we have switched
439817d28d4f add warning about unstable attachment xmlrpc API
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 756
diff changeset
911 # attachments (1.5 style) to mimetype items (hopefully in 1.6).
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
912 # They will be partly removed, esp. the semantics of the function "listAttachments"
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
913 # cannot be sensibly defined for items.
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
914 # If the first beta or more stable release of 1.6 will have new item semantics,
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
915 # we will remove the functions before it is released.
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
916 def xmlrpc_listAttachments(self, pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
917 """ Get all attachments associated with pagename
954
a7e98fd10e97 Added dummy auth token methods for XMLRPC, reworded comments.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 787
diff changeset
918 Deprecated.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
919
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
920 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
921 @rtype: list
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
922 @return: a list of utf-8 attachment names
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
923 """
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
924 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
925 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
926 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
927 return self.notAllowedFault()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
928
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
929 result = AttachFile._get_files(self.request, pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
930 return result
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
931
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
932 def xmlrpc_getAttachment(self, pagename, attachname):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
933 """ Get attachname associated with pagename
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
934
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
935 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
936 @param attachname: attachment name (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
937 @rtype base64
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
938 @return base64 data
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
939 """
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
940 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
941 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
942 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
943 return self.notAllowedFault()
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
944
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
945 filename = wikiutil.taintfilename(self._instr(attachname))
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
946 filename = AttachFile.getFilename(self.request, pagename, filename)
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
947 if not os.path.isfile(filename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
948 return self.noSuchPageFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
949 return self._outlob(open(filename, 'rb').read())
756
df1f57a8a286 Fix to the getAttachment XMLRPC method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 740
diff changeset
950
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
951 def xmlrpc_putAttachment(self, pagename, attachname, data):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
952 """ Set attachname associated with pagename to data
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2181
diff changeset
953
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
954 @param pagename: pagename (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
955 @param attachname: attachment name (utf-8)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
956 @param data: file data (base64)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
957 @rtype boolean
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
958 @return True if attachment was set
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
959 """
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
960 pagename = self._instr(pagename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
961 # User may read page?
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
962 if not self.request.user.may.read(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
963 return self.notAllowedFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
964
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
965 # also check ACLs
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
966 if not self.request.user.may.write(pagename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
967 return xmlrpclib.Fault(1, "You are not allowed to edit this page")
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
968
740
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
969 attachname = wikiutil.taintfilename(attachname)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
970 filename = AttachFile.getFilename(self.request, pagename, attachname)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
971 if os.path.exists(filename) and not os.path.isfile(filename):
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
972 return self.noSuchPageFault()
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
973 open(filename, 'wb+').write(data.data)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
974 AttachFile._addLogEntry(self.request, 'ATTNEW', pagename, filename)
0ec051831d52 Add listAttachments, getAttachment, and putAttachment to the xmlrpc api. (Thanks to Matthew Gilbert)
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 637
diff changeset
975 return xmlrpclib.Boolean(1)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
976
2472
4e9370e2e8f1 Move xmlrpc_getBotTranslations() out of warning's scope.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2462
diff changeset
977 # XXX END WARNING XXX
4e9370e2e8f1 Move xmlrpc_getBotTranslations() out of warning's scope.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2462
diff changeset
978
2461
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
979
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
980 def xmlrpc_getBotTranslations(self):
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
981 """ Return translations to be used by notification bot
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
982
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
983 @return: a dict (indexed by language) of dicts of translated strings (indexed by original ones)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
984 """
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
985 from MoinMoin.i18n import bot_translations
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
986 return bot_translations(self.request)
f456dc2048d1 i18n should now work. First step, no caching yet.
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2386
diff changeset
987
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
988
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
989 class XmlRpc1(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
990
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
991 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
992 XmlRpcBase.__init__(self, request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
993 self.version = 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
994
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
995 def _instr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
996 """ Convert string we get from xmlrpc into internal representation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
997
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
998 @param text: quoted text (str or unicode object)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
999 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1000 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1001 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1002 return wikiutil.url_unquote(text) # config.charset must be utf-8
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1003
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1004 def _outstr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1005 """ Convert string from internal representation to xmlrpc
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1006
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1007 @param text: unicode or string in config.charset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1008 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1009 @return: text encoded in utf-8 and quoted
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1010 """
101
2202f548cbb0 use own urllib wrapper, see wikiutil
Thomas Waldmann <tw@waldmann-edv.de>
parents: 53
diff changeset
1011 return wikiutil.url_quote(text) # config.charset must be utf-8
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1012
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1013
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1014 class XmlRpc2(XmlRpcBase):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1015
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1016 def __init__(self, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1017 XmlRpcBase.__init__(self, request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1018 self.version = 2
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1019
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1020 def _instr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1021 """ Convert string we get from xmlrpc into internal representation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1022
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1023 @param text: unicode or utf-8 string
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1024 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1025 @return: text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1026 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1027 if not isinstance(text, unicode):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1028 text = unicode(text, 'utf-8')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1029 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1030
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1031 def _outstr(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1032 """ Convert string from internal representation to xmlrpc
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1033
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1034 @param text: unicode or string in config.charset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1035 @rtype: str
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1036 @return: text encoded in utf-8
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1037 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1038 if isinstance(text, unicode):
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1039 text = text.encode('utf-8')
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1040 elif config.charset != 'utf-8':
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 974
diff changeset
1041 text = unicode(text, config.charset).encode('utf-8')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1042 return text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1043
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1044
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1045 def xmlrpc(request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1046 XmlRpc1(request).process()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1047
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1048
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1049 def xmlrpc2(request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1050 XmlRpc2(request).process()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1051