-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified code to run on both dmsmail versions
- Loading branch information
Showing
2 changed files
with
10 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
from imio.helpers.content import object_values | ||
from zope.annotation import IAnnotations | ||
|
||
from plone import api | ||
|
||
import logging | ||
import transaction | ||
|
||
|
||
portal = obj # noqa | ||
|
||
logger = logging.getLogger('del dv') | ||
types = ['dmsincomingmail', 'dmsincoming_email', 'dmsoutgoingmail'] | ||
count = 0 | ||
|
||
pc = portal.portal_catalog | ||
brains = pc.unrestrictedSearchResults(portal_type=types) | ||
for brain in brains: | ||
mail = brain.getObject() | ||
for fobj in object_values(mail, ['DmsFile', 'DmsAppendixFile', 'ImioDmsFile']): | ||
annot = IAnnotations(fobj) | ||
if 'collective.documentviewer' not in annot: | ||
continue | ||
del annot['collective.documentviewer'] | ||
for contained in mail.objectValues(): | ||
if contained.__class__.__name__ in ['DmsFile', 'DmsAppendixFile', 'ImioDmsFile']: | ||
count += 1 | ||
api.content.delete(obj=contained, check_linkintegrity=False) | ||
|
||
logger.warn('Deleted {} files'.format(count)) | ||
transaction.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters