Show More
@@ -193,7 +193,10 b' class hybrid(wrapped):' | |||||
193 | def _wrapvalue(self, key, val): |
|
193 | def _wrapvalue(self, key, val): | |
194 | if val is None: |
|
194 | if val is None: | |
195 | return |
|
195 | return | |
196 | return wraphybridvalue(self, key, val) |
|
196 | if util.safehasattr(val, '_makemap'): | |
|
197 | # a nested hybrid list/dict, which has its own way of map operation | |||
|
198 | return val | |||
|
199 | return mappable(None, key, val, self._makemap) | |||
197 |
|
200 | |||
198 | def itermaps(self, context): |
|
201 | def itermaps(self, context): | |
199 | makemap = self._makemap |
|
202 | makemap = self._makemap | |
@@ -422,20 +425,6 b' def unwraphybrid(context, mapping, thing' | |||||
422 | return thing |
|
425 | return thing | |
423 | return thing.show(context, mapping) |
|
426 | return thing.show(context, mapping) | |
424 |
|
427 | |||
425 | def wraphybridvalue(container, key, value): |
|
|||
426 | """Wrap an element of hybrid container to be mappable |
|
|||
427 |
|
||||
428 | The key is passed to the makemap function of the given container, which |
|
|||
429 | should be an item generated by iter(container). |
|
|||
430 | """ |
|
|||
431 | makemap = getattr(container, '_makemap', None) |
|
|||
432 | if makemap is None: |
|
|||
433 | return value |
|
|||
434 | if util.safehasattr(value, '_makemap'): |
|
|||
435 | # a nested hybrid list/dict, which has its own way of map operation |
|
|||
436 | return value |
|
|||
437 | return mappable(None, key, value, makemap) |
|
|||
438 |
|
||||
439 | def compatdict(context, mapping, name, data, key='key', value='value', |
|
428 | def compatdict(context, mapping, name, data, key='key', value='value', | |
440 | fmt=None, plural=None, separator=' '): |
|
429 | fmt=None, plural=None, separator=' '): | |
441 | """Wrap data like hybriddict(), but also supports old-style list template |
|
430 | """Wrap data like hybriddict(), but also supports old-style list template |
General Comments 0
You need to be logged in to leave comments.
Login now