add call to convert existing files to blob files
This commit is contained in:
parent
336f494e4d
commit
6cf0433ed0
|
@ -35,4 +35,11 @@
|
|||
permission="cmf.ManagePortal"
|
||||
/>
|
||||
|
||||
<browser:view
|
||||
name="updatetoblobs"
|
||||
for="*"
|
||||
class=".migration.UpdateToBlobs"
|
||||
permission="cmf.ManagePortal"
|
||||
/>
|
||||
|
||||
</configure>
|
||||
|
|
|
@ -467,3 +467,18 @@ class FixRelatedDocs(BrowserView):
|
|||
setattr(object, attr, [v])
|
||||
|
||||
|
||||
class UpdateToBlobs(BrowserView):
|
||||
def __call__(self):
|
||||
catalog = getToolByName(self.context, 'portal_catalog')
|
||||
for brain in catalog.search({'portal_type': ['bqrD', 'bulletintravauxD'}):
|
||||
object = brain.getObject()
|
||||
for attr in ("fichier", "document_imprime"):
|
||||
try:
|
||||
v = getattr(object, attr)
|
||||
except AttributeError:
|
||||
continue
|
||||
if v is None:
|
||||
continue
|
||||
print 'transforming file in', object.id
|
||||
newv = NamedFile(v.data, filemane=v.filename)
|
||||
setattr(object, attr, newv)
|
||||
|
|
Reference in New Issue