Skip to content

Commit 298fe1f

Browse files
author
Richard Jones
committed
export now stores file "content" in separate files in export directory
1 parent 3fa0a8d commit 298fe1f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

roundup/backends/back_metakit.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.74 2004-06-11 15:50:24 wc2so1 Exp $
1+
# $Id: back_metakit.py,v 1.75 2004-06-24 07:10:12 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -44,7 +44,7 @@
4444
from roundup import hyperdb, date, password, roundupdb, security
4545
import metakit
4646
from sessions_dbm import Sessions, OneTimeKeys
47-
import re, marshal, os, sys, time, calendar
47+
import re, marshal, os, sys, time, calendar, shutil
4848
from indexer_dbm import Indexer
4949
import locking
5050
from roundup.date import Range
@@ -496,7 +496,7 @@ def create_inner(self, **propvalues):
496496
ndx = self.getview(READWRITE).append(rowdict)
497497
propvalues['#ISNEW'] = 1
498498
try:
499-
self.set(str(newid), **propvalues)
499+
self.set_inner(str(newid), **propvalues)
500500
except Exception:
501501
self.maxid -= 1
502502
raise
@@ -801,7 +801,7 @@ def set_inner(self, nodeid, **propvalues):
801801
oldnode[key] = oldvalue
802802

803803
# nothing to do?
804-
if not propvalues:
804+
if not isnew and not propvalues:
805805
return propvalues, oldnode
806806
if not propvalues.has_key('activity'):
807807
row.activity = int(time.time())
@@ -1832,6 +1832,29 @@ def gen_filename(self, nodeid):
18321832
os.makedirs(d)
18331833
return os.path.join(d, nm)
18341834

1835+
def export_files(self, dirname, nodeid):
1836+
''' Export the "content" property as a file, not csv column
1837+
'''
1838+
source = self.gen_filename(nodeid)
1839+
x, filename = os.path.split(source)
1840+
x, subdir = os.path.split(x)
1841+
dest = os.path.join(dirname, self.classname+'-files', subdir, filename)
1842+
if not os.path.exists(os.path.dirname(dest)):
1843+
os.makedirs(os.path.dirname(dest))
1844+
shutil.copyfile(source, dest)
1845+
1846+
def import_files(self, dirname, nodeid):
1847+
''' Import the "content" property as a file
1848+
'''
1849+
dest = self.gen_filename(nodeid)
1850+
x, filename = os.path.split(dest)
1851+
x, subdir = os.path.split(x)
1852+
source = os.path.join(dirname, self.classname+'-files', subdir,
1853+
filename)
1854+
if not os.path.exists(os.path.dirname(dest)):
1855+
os.makedirs(os.path.dirname(dest))
1856+
shutil.copyfile(source, dest)
1857+
18351858
def get(self, nodeid, propname, default=_marker, cache=1):
18361859
if propname == 'content':
18371860
poss_msg = 'Possibly an access right configuration problem.'

0 commit comments

Comments
 (0)