Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.wikisync.MoinRemoteWiki Class Reference
Inheritance diagram for MoinMoin.wikisync.MoinRemoteWiki:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.wikisync.MoinRemoteWiki:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def createConnection
def get_diff_pre
def get_diff_post
def merge_diff_pre
def merge_diff_post
def delete_page_pre
def delete_page_post
def create_multicall_object
def prepare_multicall
def delete_auth_token
def get_interwiki_name
def get_iwid
def get_pages
def __repr__

Public Attributes

 request
 prefix
 pagelist
 verbose
 wiki_url
 valid
 xmlrpc_url
 connection
 token
 remote_interwikiname
 remote_iwid
 is_anonymous
 iwid_full

Detailed Description

Used for MoinMoin wikis reachable via XMLRPC. 

Definition at line 159 of file wikisync.py.


Constructor & Destructor Documentation

def MoinMoin.wikisync.MoinRemoteWiki.__init__ (   self,
  request,
  interwikiname,
  prefix,
  pagelist,
  user,
  password,
  verbose = False 
)

Definition at line 161 of file wikisync.py.

00161 
00162     def __init__(self, request, interwikiname, prefix, pagelist, user, password, verbose=False):
00163         self.request = request
00164         self.prefix = prefix
00165         self.pagelist = pagelist
00166         self.verbose = verbose
00167         _ = self.request.getText
00168 
00169         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwikiname, '')
00170         self.wiki_url = wikiutil.mapURL(self.request, wikiurl)
00171         self.valid = not wikitag_bad
00172         self.xmlrpc_url = self.wiki_url + "?action=xmlrpc2"
00173         if not self.valid:
00174             self.connection = None
00175             return
00176 
00177         self.connection = self.createConnection()
00178 
00179         try:
00180             iw_list = self.connection.interwikiName()
00181         except socket.error:
00182             raise UnsupportedWikiException(_("The wiki is currently not reachable."))
00183         except xmlrpclib.Fault, err:
00184             raise UnsupportedWikiException("xmlrpclib.Fault: %s" % str(err))
00185 
00186         if user and password:
00187             token = self.connection.getAuthToken(user, password)
00188             if token:
00189                 self.token = token
00190             else:
00191                 raise NotAllowedException(_("Invalid username or password."))
00192         else:
00193             self.token = None
00194 
00195         self.remote_interwikiname = remote_interwikiname = iw_list[0]
00196         self.remote_iwid = remote_iwid = iw_list[1]
00197         self.is_anonymous = remote_interwikiname is None
00198         if not self.is_anonymous and interwikiname != remote_interwikiname:
00199             raise UnsupportedWikiException(_("The remote wiki uses a different InterWiki name (%(remotename)s)"
00200                                              " internally than you specified (%(localname)s).") % {
00201                 "remotename": wikiutil.escape(remote_interwikiname), "localname": wikiutil.escape(interwikiname)})
00202 
00203         if self.is_anonymous:
00204             self.iwid_full = packLine([remote_iwid])
00205         else:
00206             self.iwid_full = packLine([remote_iwid, interwikiname])


Member Function Documentation

Returns a representation of the instance for debugging purposes. 

Reimplemented from MoinMoin.wikisync.RemoteWiki.

Definition at line 300 of file wikisync.py.

00300 
00301     def __repr__(self):
00302         return "<MoinRemoteWiki wiki_url=%r valid=%r>" % (getattr(self, "wiki_url", Ellipsis), getattr(self, "valid", Ellipsis))
00303 

Generates an object that can be used like a MultiCall instance. 

Definition at line 249 of file wikisync.py.

00249 
00250     def create_multicall_object(self):
00251         """ Generates an object that can be used like a MultiCall instance. """
00252         return xmlrpclib.MultiCall(self.connection)

Definition at line 207 of file wikisync.py.

00207 
00208     def createConnection(self):
00209         return xmlrpclib.ServerProxy(self.xmlrpc_url, allow_none=True, verbose=self.verbose)

Definition at line 261 of file wikisync.py.

00261 
00262     def delete_auth_token(self):
00263         if self.token:
00264             self.connection.deleteAuthToken(self.token)
00265             self.token = None

Processes the return value of the call generated by delete_page_pre. 

Definition at line 241 of file wikisync.py.

00241 
00242     def delete_page_post(self, result):
00243         """ Processes the return value of the call generated by delete_page_pre. """
00244         if isinstance(result, xmlrpclib.Fault):
00245             if result.faultCode == "NOT_ALLOWED":
00246                 return result.faultString
00247             raise result
00248         return ""

def MoinMoin.wikisync.MoinRemoteWiki.delete_page_pre (   self,
  pagename,
  last_remote_rev,
  interwiki_name 
)
Deletes a remote page. Generates the call. 

Definition at line 237 of file wikisync.py.

00237 
00238     def delete_page_pre(self, pagename, last_remote_rev, interwiki_name):
00239         """ Deletes a remote page. Generates the call. """
00240         return "mergeDiff", (pagename, None, None, None, last_remote_rev, interwiki_name, None)

Processes the return value of the call generated by get_diff_pre. 

Definition at line 216 of file wikisync.py.

00216 
00217     def get_diff_post(self, value):
00218         """ Processes the return value of the call generated by get_diff_pre. """
00219         if isinstance(value, xmlrpclib.Fault):
00220             if value.faultCode == "INVALID_TAG":
00221                 return None
00222             raise value
00223         value["diff"] = str(value["diff"]) # unmarshal Binary object
00224         return value

def MoinMoin.wikisync.MoinRemoteWiki.get_diff_pre (   self,
  pagename,
  from_rev,
  to_rev,
  n_name = None 
)
Returns the binary diff of the remote page named pagename, given
    from_rev and to_rev. Generates the call. 

Definition at line 211 of file wikisync.py.

00211 
00212     def get_diff_pre(self, pagename, from_rev, to_rev, n_name=None):
00213         """ Returns the binary diff of the remote page named pagename, given
00214             from_rev and to_rev. Generates the call. """
00215         return "getDiff", (pagename, from_rev, to_rev, n_name)

Returns the interwiki name of the other wiki. 

Reimplemented from MoinMoin.wikisync.RemoteWiki.

Definition at line 268 of file wikisync.py.

00268 
00269     def get_interwiki_name(self):
00270         return self.remote_interwikiname

Returns the InterWiki ID. 

Reimplemented from MoinMoin.wikisync.RemoteWiki.

Definition at line 271 of file wikisync.py.

00271 
00272     def get_iwid(self):
00273         return self.remote_iwid

Returns a list of SyncPage instances. 

Reimplemented from MoinMoin.wikisync.RemoteWiki.

Definition at line 274 of file wikisync.py.

00274 
00275     def get_pages(self, **kwargs):
00276         options = {"include_revno": True,
00277                    "include_deleted": True,
00278                    "exclude_non_writable": kwargs["exclude_non_writable"],
00279                    "include_underlay": False,
00280                    "prefix": self.prefix,
00281                    "pagelist": self.pagelist,
00282                    "mark_deleted": True}
00283         if self.token:
00284             m = xmlrpclib.MultiCall(self.connection)
00285             m.applyAuthToken(self.token)
00286             m.getAllPagesEx(options)
00287             tokres, pages = m()
00288         else:
00289             pages = self.connection.getAllPagesEx(options)
00290         rpages = []
00291         for name, revno in pages:
00292             normalised_name = normalise_pagename(name, self.prefix)
00293             if normalised_name is None:
00294                 continue
00295             if abs(revno) != 99999999: # I love sane in-band signalling
00296                 remote_rev = abs(revno)
00297                 remote_deleted = revno < 0
00298                 rpages.append(SyncPage(normalised_name, remote_rev=remote_rev, remote_name=name, remote_deleted=remote_deleted))
00299         return rpages

Here is the call graph for this function:

Processes the return value of the call generated by merge_diff_pre.  

Definition at line 229 of file wikisync.py.

00229 
00230     def merge_diff_post(self, result):
00231         """ Processes the return value of the call generated by merge_diff_pre.  """
00232         if isinstance(result, xmlrpclib.Fault):
00233             if result.faultCode == "NOT_ALLOWED":
00234                 raise NotAllowedException
00235             raise result
00236         return result

def MoinMoin.wikisync.MoinRemoteWiki.merge_diff_pre (   self,
  pagename,
  diff,
  local_rev,
  delta_remote_rev,
  last_remote_rev,
  interwiki_name,
  n_name 
)
Merges the diff into the page on the remote side. Generates the call. 

Definition at line 225 of file wikisync.py.

00225 
00226     def merge_diff_pre(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, n_name):
00227         """ Merges the diff into the page on the remote side. Generates the call. """
00228         return "mergeDiff", (pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name, n_name)

Can be used to return initial calls that e.g. authenticate the user.
    @return: [(funcname, (arg,+)*]

Definition at line 253 of file wikisync.py.

00253 
00254     def prepare_multicall(self):
00255         """ Can be used to return initial calls that e.g. authenticate the user.
00256             @return: [(funcname, (arg,+)*]
00257         """
00258         if self.token:
00259             return [("applyAuthToken", (self.token, ))]
00260         return []


Member Data Documentation

Definition at line 173 of file wikisync.py.

Definition at line 196 of file wikisync.py.

Definition at line 203 of file wikisync.py.

Definition at line 164 of file wikisync.py.

Definition at line 163 of file wikisync.py.

Definition at line 194 of file wikisync.py.

Definition at line 195 of file wikisync.py.

Definition at line 162 of file wikisync.py.

Definition at line 188 of file wikisync.py.

Definition at line 170 of file wikisync.py.

Definition at line 165 of file wikisync.py.

Definition at line 169 of file wikisync.py.

Definition at line 171 of file wikisync.py.


The documentation for this class was generated from the following file: