python - It is possible to run a transmogrifier section after all other have completely run? -
i'm importing content plone using transmogrifier pipeline and, in order fix various aspects images, links , related content, need run section after content has been created , indexed.
i need because want use catalog tool in order search content path , use uuid referrer it.
is possible using transmogrifier or it's better using other of technologies available, simple upgrade step?
i thinking on using pattern similar source section:
from collective.transmogrifier.interfaces import isection collective.transmogrifier.interfaces import isectionblueprint class dosomethingattheveryendsection(object): classprovides(isectionblueprint) implements(isection) def __init__(self, transmogrifier, name, options, previous): self.previous = previous def __iter__(self): item in self.previous: yield item item in self.previous: do_something()
is idea?
yes, idea make postprocess section, problem self.previous
generator can't called 2 times way.
a workaround use itertools.tee duplicate generator, way can walk 2 times generator:
from collective.transmogrifier.interfaces import isection collective.transmogrifier.interfaces import isectionblueprint import itertools class dosomethingattheveryendsection(object): classprovides(isectionblueprint) implements(isection) def __init__(self, transmogrifier, name, options, previous): self.previous = previous def __iter__(self): self.previous, self.postprocess = itertools.tee(self.previous) item in self.previous: yield item item in self.postprocess: do_something()
Comments
Post a Comment