[Erp5-report] r25658 - /erp5/trunk/utils/zodb-cutter/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Feb 23 13:54:11 CET 2009
Author: nicolas
Date: Mon Feb 23 13:54:08 2009
New Revision: 25658
URL: http://svn.erp5.org?rev=25658&view=rev
Log:
-Add prefix_file parameter to prefix Filename
-Add a method to test if all objects are there before cutting
Modified:
erp5/trunk/utils/zodb-cutter/cutter.py
erp5/trunk/utils/zodb-cutter/cutter_cluster_config_generator.py
erp5/trunk/utils/zodb-cutter/cutter_config.py
Modified: erp5/trunk/utils/zodb-cutter/cutter.py
URL: http://svn.erp5.org/erp5/trunk/utils/zodb-cutter/cutter.py?rev=25658&r1=25657&r2=25658&view=diff
==============================================================================
--- erp5/trunk/utils/zodb-cutter/cutter.py [utf8] (original)
+++ erp5/trunk/utils/zodb-cutter/cutter.py [utf8] Mon Feb 23 13:54:08 2009
@@ -56,6 +56,12 @@
"""Get application to operate on"""
app = root
for rc in config.application:
+ app = app[rc]
+ return app
+
+def getModule(config, root, module_name):
+ app = root
+ for rc in config.application + [module_name]:
app = app[rc]
return app
@@ -131,6 +137,27 @@
os.remove('%s.old' % destination_file)
print 'done (%.3fs).' % (time() - b)
+def checkAll(config, cut_list):
+ from Products.ERP5Type.Core import Folder
+ sys.modules['Products.ERP5Type.Document.Folder'] = Folder
+ source_storage = FileStorage.FileStorage(config.source_file)
+ db = DB(source_storage)
+ conn = db.open()
+ dbroot = conn.root()
+
+ app = getApp(config, dbroot)
+ for cut in cut_list:
+ orig_module = app[cut]
+ filename = '%s%s.fs' % (config.prefix_file, cut)
+ dest_storage = FileStorage.FileStorage(os.path.join(config.data_directory,
+ filename))
+ db_dest = DB(dest_storage)
+ conn_dest = db_dest.open()
+ dbroot_dest = conn_dest.root()
+ dest_module = getModule(config, dbroot_dest, cut)
+ assert len(orig_module), len(dest_module)
+ assert [id for id in orig_module.objectIds()], [id for id in dest_module.objectIds()]
+ db_dest.close()
def main():
# Work begin
@@ -152,10 +179,13 @@
# Remove everything except wanted module
for module_name in cut_list:
- cutAll(config, module_name + '.fs', [module_name], False)
+ filename = '%s%s.fs' % (config.prefix_file, module_name)
+ cutAll(config, filename, [module_name], False)
# create root-mount file
cutAll(config, config.destination_file, cut_list, True)
+ #check that every Object is there
+ checkAll(config, cut_list)
# Works ends
print "Global execution time is %.3fs" % (time() - global_time)
Modified: erp5/trunk/utils/zodb-cutter/cutter_cluster_config_generator.py
URL: http://svn.erp5.org/erp5/trunk/utils/zodb-cutter/cutter_cluster_config_generator.py?rev=25658&r1=25657&r2=25658&view=diff
==============================================================================
--- erp5/trunk/utils/zodb-cutter/cutter_cluster_config_generator.py [utf8] (original)
+++ erp5/trunk/utils/zodb-cutter/cutter_cluster_config_generator.py [utf8] Mon Feb 23 13:54:08 2009
@@ -75,17 +75,18 @@
""" % (config.zeo_server_config[zeo_server]))
for module_name, cluster_config in config.cluster_mount_configuration.iteritems():
+ prefix = config.prefix_file
if cluster_config['zeo'] == zeo_server:
if module_name == '/': # special case
mount_point = module_name
module_name = config.destination_file.split('.fs')[0]
else:
mount_point = config.root_mount + module_name
- zeo_config_file.write("""<filestorage %s>
- path $INSTANCE/var/%s.fs
+ zeo_config_file.write("""<filestorage %(module_name)s>
+ path $INSTANCE/var/%(prefix)s%(module_name)s.fs
</filestorage>
-""" % (module_name,module_name))
+""" % {'prefix':prefix, 'module_name': module_name})
zope_config_file.write("""<zodb_db %(module-name)s>
mount-point %(mount-point)s
# ZODB cache, in number of objects
Modified: erp5/trunk/utils/zodb-cutter/cutter_config.py
URL: http://svn.erp5.org/erp5/trunk/utils/zodb-cutter/cutter_config.py?rev=25658&r1=25657&r2=25658&view=diff
==============================================================================
--- erp5/trunk/utils/zodb-cutter/cutter_config.py [utf8] (original)
+++ erp5/trunk/utils/zodb-cutter/cutter_config.py [utf8] Mon Feb 23 13:54:08 2009
@@ -39,6 +39,9 @@
# directory for Data.fs files - needs much of space
data_directory = 'data'
+
+#Prefix for Cutted datafs filename
+prefix_file = ''
# directory for configuration
config_directory = 'config'
More information about the Erp5-report
mailing list