Last change
on this file since 1589 was
275,
checked in by mylan, 18 years ago
|
Removed file/folder
|
File size:
843 bytes
|
Rev | Line | |
---|
[275] | 1 | from zope.interface import classProvides, implements |
---|
| 2 | from collective.transmogrifier.interfaces import ISectionBlueprint |
---|
| 3 | from collective.transmogrifier.interfaces import ISection |
---|
| 4 | |
---|
| 5 | class SubstitutionSection(object): |
---|
| 6 | classProvides(ISectionBlueprint) |
---|
| 7 | implements(ISection) |
---|
| 8 | |
---|
| 9 | def __init__(self, transmogrifier, name, options, previous): |
---|
| 10 | self.key = options['key'].strip() |
---|
| 11 | self.oldkey = "_old" + self.key |
---|
| 12 | self.options = options |
---|
| 13 | self.previous = previous |
---|
| 14 | |
---|
| 15 | def __iter__(self): |
---|
| 16 | key = self.key |
---|
| 17 | for item in self.previous: |
---|
| 18 | if key in item: |
---|
| 19 | old = item[key] |
---|
| 20 | new = self.options.get(item[key]) |
---|
| 21 | if new is not None and old != new: |
---|
| 22 | item[key] = new.strip() |
---|
| 23 | item[self.oldkey] = old |
---|
| 24 | yield item |
---|
Note: See
TracBrowser
for help on using the repository browser.