Commit e5090825 authored by Bartek Górny's avatar Bartek Górny

add serPropertyListFromContent method

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11233 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5ad30d63
......@@ -106,6 +106,8 @@ class OOoDocument(DMSFile, CachingMixin):
, PropertySheet.OOoDocument
)
# regexp for finding attrs in content
rx_atr=re.compile('([\w]+)###([\w/]+)')
# regexps for stripping xml from docs
rx_strip=re.compile('<[^>]*?>',re.DOTALL|re.MULTILINE)
rx_compr=re.compile('\s+')
......@@ -243,6 +245,26 @@ class OOoDocument(DMSFile, CachingMixin):
z.close()
return s
security.declareProtected(Permissions.ModifyPortalContent,'setPropertyListFromContent')
def setPropertyListFromContent(self,data):
cs=cStringIO.StringIO()
cs.write(self._unpackData(data))
try:
z=zipfile.ZipFile(cs)
except zipfile.BadZipfile:
cs.close()
return
s=z.read('content.xml')
cs.close()
z.close()
atrs=dict(self.rx_atr.findall(s))
doctype=atrs.get('doctype','None')
if doctype!=self.getPortalType():
raise Exception('portal type mismatch - content gave %s, I have %s' % (doctype,self.getPortalType()))
for a in atrs:
if a not in ('author','doctype'):
self.setProperty(a,atrs[a])
security.declarePrivate('_setMetaData')
def _setMetaData(self,meta):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment