changeset 853:bc36120169a9 storage-ng

added serialization script, config import fixes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 24 Sep 2011 01:52:32 +0200
parents 5ad4ae0b1e09
children c9a78e5a58c4
files MoinMoin/script/maint/serialization.py MoinMoin/storage/backends/_tests/__init__.py MoinMoin/storage/backends/_tests/test_fileserver.py MoinMoin/storage/middleware/_tests/test_indexing.py MoinMoin/storage/middleware/_tests/test_protecting.py MoinMoin/storage/middleware/_tests/test_routing.py MoinMoin/storage/middleware/routing.py
diffstat 7 files changed, 43 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/maint/serialization.py	Sat Sep 24 01:52:32 2011 +0200
@@ -0,0 +1,37 @@
+# Copyright: 2011 MoinMoin:ThomasWaldmann
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+MoinMoin - backend serialization / deserialization
+"""
+
+
+from flask import current_app as app
+from flask import g as flaskg
+from flaskext.script import Command, Option
+
+from MoinMoin.storage.middleware.serialization import serialize, deserialize
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
+class Serialize(Command):
+    description = 'Serialize the backend into a file.'
+
+    option_list = [
+    ]
+
+    def run(self, filename="dump"):
+        serialize(app.storage.backend, open(filename, "wb"))
+
+
+class Deserialize(Command):
+    description = 'Deserialize a file into the backend.'
+
+    option_list = [
+    ]
+
+    def run(self, filename="dump"):
+        deserialize(open(filename, "rb"), app.storage.backend)
+
--- a/MoinMoin/storage/backends/_tests/__init__.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/backends/_tests/__init__.py	Sat Sep 24 01:52:32 2011 +0200
@@ -12,7 +12,7 @@
 
 import pytest
 
-from config import SIZE, HASH_ALGORITHM
+from MoinMoin.config import SIZE, HASH_ALGORITHM
 
 class BackendTestBase(object):
     def setup_method(self, method):
--- a/MoinMoin/storage/backends/_tests/test_fileserver.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/backends/_tests/test_fileserver.py	Sat Sep 24 01:52:32 2011 +0200
@@ -13,7 +13,7 @@
 
 import pytest
 
-from config import MTIME
+from MoinMoin.config import MTIME
 from ..fileserver import Backend
 from . import BackendTestBase
 
--- a/MoinMoin/storage/middleware/_tests/test_indexing.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/middleware/_tests/test_indexing.py	Sat Sep 24 01:52:32 2011 +0200
@@ -13,7 +13,7 @@
 
 import pytest
 
-from config import NAME, SIZE, ITEMID, REVID, DATAID, HASH_ALGORITHM, CONTENT, COMMENT
+from MoinMoin.config import NAME, SIZE, ITEMID, REVID, DATAID, HASH_ALGORITHM, CONTENT, COMMENT
 
 from ..indexing import IndexingMiddleware
 
--- a/MoinMoin/storage/middleware/_tests/test_protecting.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/middleware/_tests/test_protecting.py	Sat Sep 24 01:52:32 2011 +0200
@@ -12,7 +12,7 @@
 
 import pytest
 
-from config import ACL
+from MoinMoin.config import ACL
 
 from ..protecting import ProtectingMiddleware, AccessDenied
 
--- a/MoinMoin/storage/middleware/_tests/test_routing.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/middleware/_tests/test_routing.py	Sat Sep 24 01:52:32 2011 +0200
@@ -12,7 +12,7 @@
 
 import pytest
 
-from config import NAME, REVID
+from MoinMoin.config import NAME, REVID
 
 from ..routing import Backend as RouterBackend
 
--- a/MoinMoin/storage/middleware/routing.py	Sat Sep 24 01:22:29 2011 +0200
+++ b/MoinMoin/storage/middleware/routing.py	Sat Sep 24 01:52:32 2011 +0200
@@ -17,7 +17,7 @@
 
 from __future__ import absolute_import, division
 
-from config import NAME
+from MoinMoin.config import NAME
 
 from MoinMoin.storage.backends import BackendBase, MutableBackendBase
 
@@ -76,7 +76,6 @@
                 yield u'%s/%s' % (mountpoint, revid)
 
     def retrieve(self, revid):
-        print revid
         mountpoint, revid = revid.rsplit(u'/', 1)
         backend = self._get_backend(mountpoint)[0]
         meta, data = backend.retrieve(revid)