Skip to content

Commit

Permalink
export member file attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
ejucovy committed Apr 11, 2015
1 parent 194fc58 commit 6e09bc9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions opencore/scripts/export_member_wikis.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ def export_one_member(folder, namespace, archive_prefix):
json.dumps(filename_map))
if namespace == "people":

file_metadata = {}
for afile in folder.portal_catalog(
portal_type=("FileAttachment", "Image"), path='/'.join(folder.getPhysicalPath())):

obj = afile.getObject()
relative_path = afile.getPath()[len('/'.join(folder.getPhysicalPath())):].lstrip('/')
out_path = "%s/pages/%s" % (archive_prefix, relative_path)

metadata = {
'creator': obj.Creator(),
'creation_date': str(obj.creation_date),
'title': obj.Title(),
}
file_metadata[out_path] = metadata

if isinstance(obj.data, basestring):
zfile.writestr(out_path, str(obj))
continue
data = obj.data
import tempfile
temp = tempfile.NamedTemporaryFile(delete=True)
try:
while data is not None:
temp.write(data)
data = data.next
zfile.write(temp.name, out_path)
finally:
temp.close()
zfile.writestr("%s/attachments.json" % archive_prefix,
json.dumps(file_metadata))


_msgs = ITransientMessage(folder.openplans).get_all_msgs(folder.getId())
msgs = {}
for category in _msgs:
Expand Down

0 comments on commit 6e09bc9

Please sign in to comment.