Skip to content

Commit

Permalink
When doing an export with export_content and having constraints to sk…
Browse files Browse the repository at this point in the history
…ip items, still allow to walk into subitems of the skipped ones - except for skipped paths, where the whole path is skipped.
  • Loading branch information
thet committed Oct 28, 2015
1 parent 732c81a commit eadce5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changelog
1.2 (unreleased)
----------------

- Nothing changed yet.
- When doing an export with ``export_content`` and having constraints to skip
items, still allow to walk into subitems of the skipped ones - except for
skipped paths, where the whole path is skipped.
[thet]


1.1 (2015-10-22)
Expand Down
18 changes: 12 additions & 6 deletions collective/jsonify/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,27 @@ def walk(folder, skip_callback=lambda item: False):
for item_id in folder.objectIds():
item = folder[item_id]

yield_item = True
path = '/'.join(item.getPhysicalPath())
if filter(lambda x: x in path, PATHS_TO_SKIP)\
or item.__class__.__name__ in CLASSNAME_TO_SKIP\
or item.getId() in ID_TO_SKIP:
if filter(lambda x: x in path, PATHS_TO_SKIP):
# Skip the whole path, including subdirectories
continue
if item.__class__.__name__ in CLASSNAME_TO_SKIP\
or item.getId() in ID_TO_SKIP:
yield_item = False
if item.__class__.__name__ in CLASSNAME_TO_SKIP_LOUD:
logger.warn('>> SKIPPING :: [%s] %s' % (
item.__class__.__name__,
item.absolute_url()
))
continue
yield_item = False
if skip_callback and skip_callback(item):
continue
yield_item = False

yield item
if yield_item:
# skip yielding items, which do not fullfill constraints from above
# but allow walking into subdirectories (below)
yield item
if getattr(item, 'objectIds', None) and item.objectIds():
for subitem in walk(item, skip_callback=skip_callback):
yield subitem
Expand Down

0 comments on commit eadce5e

Please sign in to comment.