changeset 1039:e39b47ed9e2a

Merge with upstream.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 22 Jul 2006 02:00:03 +0200
parents e52ab62b3a0a (diff) b339cd4e61c9 (current diff)
children ad101845642b
files
diffstat 3 files changed, 65 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/_tests/test_wikisync.py	Sat Jul 22 02:00:03 2006 +0200
@@ -0,0 +1,33 @@
+# -*- coding: iso-8859-1 -*-
+"""
+MoinMoin - MoinMoin.wikisync tests
+
+@copyright: 2006 MoinMoin:AlexanderSchremmer
+@license: GNU GPL, see COPYING for details.
+"""
+
+from unittest import TestCase
+from MoinMoin.Page import Page
+from MoinMoin.PageEditor import PageEditor
+from MoinMoin._tests import TestConfig, TestSkipped
+
+from MoinMoin.wikisync import TagStore
+
+
+class UnsafeSyncTestcase(TestCase):
+    """ Tests various things related to syncing. Note that it is not possible
+        to create pages without cluttering page revision currently, so we have to use
+        the testwiki. """
+
+    def setUp(self):
+        if not getattr(self.request.cfg, 'is_test_wiki', False):
+            raise TestSkipped('This test needs to be run using the test wiki.')
+
+    def testBasicTagThings(self):
+        page = PageEditor(self.request, "FrontPage")
+        tags = TagStore(page)
+        self.assert_(not tags.get_all_tags())
+        tags.add(remote_wiki="foo", remote_rev=1, current_rev=2)
+        tags = TagStore(page) # reload
+        self.assert_(tags.get_all_tags()[0].remote_rev == 1)
+
--- a/MoinMoin/wikisync.py	Fri Jul 21 19:34:11 2006 +0200
+++ b/MoinMoin/wikisync.py	Sat Jul 22 02:00:03 2006 +0200
@@ -7,7 +7,7 @@
 """
 
 try:
-    import cpickle as pickle
+    import cPickle as pickle
 except ImportError:
     import pickle
 
@@ -16,31 +16,54 @@
     """ This class is used to store information about merging state. """
     
     def __init__(self, remote_wiki, remote_rev, current_rev):
+        """ Creates a new Tag.
+        
+        @param remote_wiki: The identifier of the remote wiki.
+        @param remote_rev: The revision number on the remote end.
+        @param current_rev: The related local revision.
+        """
         self.remote_wiki = remote_wiki
         self.remote_rev = remote_rev
         self.current_rev = current_rev
 
+    def __repr__(self):
+        return u"<Tag remote_wiki=%r remote_rev=%r current_rev=%r>" % (self.remote_wiki, self.remote_rev, self.current_rev)
+
 
 class AbstractTagStore(object):
     """ This class is an abstract base class that shows how to implement classes
         that manage the storage of tags. """
 
     def __init__(self, page):
+        """ Subclasses don't need to call this method. It is just here to enforce
+        them having accept a page argument at least. """
         pass
 
     def add(self, **kwargs):
+        """ Adds a Tag object to the current TagStore. """
         print "Got tag for page %r: %r" % (self.page, kwargs)
+        return NotImplemented
+
+    def get_all_tags(self):
+        """ Returns a list of all Tag objects associated to this page. """
+        return NotImplemented
 
 
 class PickleTagStore(AbstractTagStore):
     """ This class manages the storage of tags in pickle files. """
 
     def __init__(self, page):
+        """ Creates a new TagStore that uses pickle files.
+        
+        @param page: a Page object where the tags should be related to
+        """
+        
         self.page = page
         self.filename = page.getPagePath('synctags', use_underlay=0, check_create=1, isfile=1)
         self.load()
 
     def load(self):
+        """ Loads the tags from the data file. """
         try:
             datafile = file(self.filename, "rb")
         except IOError:
@@ -50,14 +73,20 @@
             datafile.close()
     
     def commit(self):
+        """ Writes the memory contents to the data file. """
         datafile = file(self.filename, "wb")
         pickle.dump(self.tags, datafile, protocol=pickle.HIGHEST_PROTOCOL)
         datafile.close()
 
-    # public methods
+    # public methods ---------------------------------------------------
     def add(self, **kwargs):
-        print "Got tag for page %r: %r" % (self.page, kwargs)
         self.tags.append(Tag(**kwargs))
         self.commit()
+    
+    def get_all_tags(self):
+        return self.tags
 
+
+# currently we just have one implementation, so we do not need
+# a factory method
 TagStore = PickleTagStore
\ No newline at end of file
--- a/MoinMoin/xmlrpc/__init__.py	Fri Jul 21 19:34:11 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sat Jul 22 02:00:03 2006 +0200
@@ -656,7 +656,6 @@
         # write page
         try:
             currentpage.saveText(newcontents.encode("utf-8"), last_remote_rev, comment=comment)
-            currentpage.clean_acl_cache()
         except PageEditor.EditConflict:
             return LASTREV_INVALID