changeset 815:185f64deed0f pytest2

merged to default
author pkumar <contactprashantat@gmail.com>
date Wed, 24 Aug 2011 09:15:57 +0530
parents 57af51410c3a (current diff) bb3ea5043a4f (diff)
children 3bfe393013e9
files MoinMoin/_tests/test_test_environ.py
diffstat 7 files changed, 66 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_test_environ.py	Tue Aug 23 23:29:22 2011 +0530
+++ b/MoinMoin/_tests/test_test_environ.py	Wed Aug 24 09:15:57 2011 +0530
@@ -50,7 +50,6 @@
 
 class TestStorageEnvironWithConfig(object):
     class Config(wikiconfig.Config):
-        load_xml = wikiconfig.Config._test_items_xml
         content_acl = dict(
             before="+All:write", # need to write to sys pages
             default="All:read,write,admin,create,destroy",
@@ -61,7 +60,7 @@
     def test_fresh_backends_with_content(self):
         # get the items from xml file
         backend = app.unprotected_storage
-        unserialize(backend, self.Config.load_xml)
+        unserialize(backend, self.Config._test_items_xml)
 
         assert isinstance(app.cfg, wikiconfig.Config)
 
--- a/MoinMoin/_tests/test_wikiutil.py	Tue Aug 23 23:29:22 2011 +0530
+++ b/MoinMoin/_tests/test_wikiutil.py	Wed Aug 24 09:15:57 2011 +0530
@@ -38,14 +38,11 @@
         'NoSuchPageYetAndWillNeverBe',
         )
 
-    class Config(wikiconfig.Config):
-        load_xml = wikiconfig.Config._test_items_xml
-
     def testSystemItem(self):
         """wikiutil: good system item names accepted, bad rejected"""
         # get the items from xml file
         backend = app.unprotected_storage
-        unserialize(backend, self.Config.load_xml)
+        unserialize(backend, wikiconfig.Config._test_items_xml)
 
         for name in self.systemItems:
             assert wikiutil.isSystemItem(name)
--- a/MoinMoin/app.py	Tue Aug 23 23:29:22 2011 +0530
+++ b/MoinMoin/app.py	Wed Aug 24 09:15:57 2011 +0530
@@ -133,8 +133,6 @@
     clock.start('create_app init backends')
     app.unprotected_storage, app.storage = init_backends(app)
     clock.stop('create_app init backends')
-    clock.start('create_app load/save xml')
-    clock.stop('create_app load/save xml')
     clock.start('create_app flask-babel')
     i18n_init(app)
     clock.stop('create_app flask-babel')
@@ -183,47 +181,6 @@
     app.unprotected_storage.close()
 
 
-def import_export_xml(app):
-    # If the content was already pumped into the backend, we don't want
-    # to do that again. (Works only until the server is restarted.)
-    xmlfile = app.cfg.load_xml
-    if xmlfile:
-        app.cfg.load_xml = None
-        tmp_backend = router.RouterBackend([('/', memory.MemoryBackend())], cfg=app.cfg)
-        unserialize(tmp_backend, xmlfile)
-        # TODO optimize this, maybe unserialize could count items it processed
-        item_count = 0
-        for item in tmp_backend.iteritems():
-            item_count += 1
-        logging.debug("loaded xml into tmp_backend: %s, %d items" % (xmlfile, item_count))
-        try:
-            # In case the server was restarted we cannot know whether
-            # the xml data already exists in the target backend.
-            # Hence we check the existence of the items before we unserialize
-            # them to the backend.
-            backend = app.unprotected_storage
-            for item in tmp_backend.iteritems():
-                item = backend.get_item(item.name)
-        except StorageError:
-            # if there is some exception, we assume that backend needs to be filled
-            # we need to use it as unserialization target so that update mode of
-            # unserialization creates the correct item revisions
-            logging.debug("unserialize xml file %s into %r" % (xmlfile, backend))
-            unserialize(backend, xmlfile)
-    else:
-        item_count = 0
-
-    # XXX wrong place / name - this is a generic preload functionality, not just for tests
-    # To make some tests happy
-    app.cfg.test_num_pages = item_count
-
-    xmlfile = app.cfg.save_xml
-    if xmlfile:
-        app.cfg.save_xml = None
-        backend = app.unprotected_storage
-        serialize(backend, xmlfile)
-
-
 def setup_user():
     """
     Try to retrieve a valid user object from the request, be it
--- a/MoinMoin/config/default.py	Tue Aug 23 23:29:22 2011 +0530
+++ b/MoinMoin/config/default.py	Wed Aug 24 09:15:57 2011 +0530
@@ -410,10 +410,6 @@
     ('namespace_mapping', None,
     "This needs to point to a (correctly ordered!) list of tuples, each tuple containing: Namespace identifier, backend, acl protection to be applied to that backend. " + \
     "E.g.: [('/', FSBackend('wiki/data'), dict(default='All:read,write,create')), ]. Please see HelpOnStorageConfiguration for further reference."),
-    ('load_xml', None,
-     'If this points to an xml file, the file is loaded into the storage backend(s) upon first request.'),
-    ('save_xml', None,
-     'If this points to an xml file, the current storage backend(s) content is saved into that file upon the first request.'),
   )),
   # ==========================================================================
   'items': ('Special item names', None, (
--- a/docs/admin/install.rst	Tue Aug 23 23:29:22 2011 +0530
+++ b/docs/admin/install.rst	Wed Aug 24 09:15:57 2011 +0530
@@ -73,6 +73,18 @@
 That way, you can have all sorts of Pythons in different virtualenv directories
 within your moin2 workdir.
 
+Loading some items
+------------------
+In case you do not want to have a completely empty wiki, you may want to load
+some items into it. We provide some in `contrib/xml` directory and you can load
+them like this::
+
+ # enter your virtual environment:
+ source env/bin/activate
+
+ # load some example items:
+ moin maint_xml --load --file=contrib/xml/preloaded_items.xml
+
 Installing PIL
 ~~~~~~~~~~~~~~
 For some image processing functions (like resizing, rotating) of moin, you
--- a/docs/admin/upgrade.rst	Tue Aug 23 23:29:22 2011 +0530
+++ b/docs/admin/upgrade.rst	Wed Aug 24 09:15:57 2011 +0530
@@ -43,12 +43,10 @@
 the moin2 sample config (do not just use your 1.9 wikiconfig).
 
 
-Configure moin2 to read moin 1.9 data
--------------------------------------
-moin2 can use the `fs19` storage backend to access your moin 1.9 content
-(pages, attachments and users).
-
-Use a **copy** of the 1.9 content, do not point it at your original data.
+Adjusting the moin2 configuration
+---------------------------------
+It is essential that you adjust the wiki config before you export your 1.9
+data to xml:
 
 Configuration::
 
@@ -66,10 +64,12 @@
     mail_login = ...
     # XXX default_markup must be 'wiki' right now
     page_category_regex = ... # XXX check
-    data_dir = ... # same as in 1.9, user profiles must be in data_dir/user
+
+    # think about which backend you will use in the end and configure
+    # it here (this is NOT the fs19 backend!):
     namespace_mapping = \
         create_simple_mapping(
-            backend_uri='fs19:%s' % data_dir,
+            backend_uri='fs2:/some/path/%%(nsname)s',
             content_acl=dict(before=u'', # acl_rights_before in 1.9
                              default=u'', # acl_rights_default
                              after=u'', # acl_rights_after
@@ -80,33 +80,52 @@
                                   hierarchic=False),
         )
 
-    save_xml = '.../backup.xml'
-    load_xml = None
-
-If you start moin now, it will serialize everything it finds in its backend
-to an xml file.
-
-Keep the xml file (you can use it to try different backend configurations).
-
-
-Writing the data to a moin2 backend
------------------------------------
-Reconfigure moin2 to use the backend you like to use (e.g. fs2 backend)::
+Exporting your moin 1.9 data to an XML file
+-------------------------------------------
+moin2 can use the `fs19` storage backend to access your moin 1.9 content
+(pages, attachments and users). The fs19 backend is a bit more than just
+a backend - it also makes the moin 1.9 data look like moin2 data when
+moin accesses them. To support this, it is essential that you adjust your
+wiki config first, see previous section.
 
-    # use same as you already have, but:
-    backend_uri='fs2:/some/path/%%(nsname)s',
-
-    save_xml = None
-    load_xml = '.../backup.xml'
+Then, use a **copy** of your 1.9 content, do not point moin2 it at your
+original data::
 
-If you start moin2 now, it will unserialize your xml file to fill the
-backend with your data.
-
+    moin maint_xml --moin19data=/your/moin19/data --save --file=moin19.xml
 
-Cleaning up the configuration
------------------------------
-You need to import the xml only once, so after doing that, clean up your config::
+This will serialize all your moin 1.9 data into moin19.xml.
 
-    save_xml = None
-    load_xml = None
+Note: depending on the size of your wiki, this can take rather long and consume
+about the same amount of additional disk space.
 
+Importing the XML file into moin2
+---------------------------------
+Just load moin19.xml into the storage backend you have already configured::
+
+    moin maint_xml --load --file=moin19.xml
+
+Note: depending on the size of your wiki, this can take rather long and consume
+about the same amount of additional disk space.
+
+Testing
+-------
+Just start moin now, it should have your data now.
+
+Try "Index" and "History" views to see what's in there.
+
+Check whether your data is complete and working OK.
+
+If you find issues with data migration from moin 1.9 to 2, please check the
+moin2 issue tracker.
+
+Cleanup
+-------
+If you made a **copy** of your 1.9 content, you can remove that copy now.
+
+Maybe keep the moin19.xml for a while in case you want to try other backends,
+but later you can delete that file.
+
+Make sure you keep all backups of your moin 1.9 installation (code, config,
+data), just for the case you are not happy with moin2 and need to go back for
+some reason.
+
--- a/wikiconfig.py	Tue Aug 23 23:29:22 2011 +0530
+++ b/wikiconfig.py	Wed Aug 24 09:15:57 2011 +0530
@@ -24,11 +24,6 @@
     data_dir = os.path.join(instance_dir, 'data') # Note: this used to have a trailing / in the past
     index_dir = os.path.join(instance_dir, "index")
     index_dir_tmp = os.path.join(instance_dir, "index_tmp")
-    # This puts the contents from the specified xml file (a serialized backend) into your
-    # backend(s). You can remove this after the first request to your wiki or
-    # from the beginning if you don't want to use this feature at all.
-    load_xml = os.path.join(wikiconfig_dir, 'contrib', 'xml', 'preloaded_items.xml')
-    #save_xml = os.path.join(wikiconfig_dir, 'contrib', 'xml', 'saved_items.xml')
 
     # This provides a simple default setup for your backend configuration.
     # 'fs:' indicates that you want to use the filesystem backend. You can also use