Commit 0a538d2d authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Vincent A

weboob.browser.elements: explicit params for ItemElementFromAbstractPage

When switching to regular imports, ItemElementFromAbstractPage will become
obsolete. However, they will not be removed immediately, but they will be
reimplemented to be compatible with the new system. But the reimplementation
works at import-time, not at exec-time, and it's not possible to access params
defined in outer scopes at import-time. So, we make sure the attributes are
explicitly defined, not implicitly.
parent dfe5807e
......@@ -424,16 +424,16 @@ class ItemElementFromAbstractPage(ItemElement):
...
... obj_label = "XXX"
"""
PARENT = None
PARENT_URL = None
ITER_ELEMENT = None
@classmethod
def _resolve_abstract(cls, page, iter_element, *args, **kwargs):
if not all(hasattr(page.__class__, attr) for attr in ('PARENT', 'PARENT_URL')):
if not (cls.PARENT and cls.PARENT_URL and cls.ITER_ELEMENT):
raise ItemElementFromAbstractPageError('page %s is not an AbstractPage' % page)
if getattr(cls, 'ITER_ELEMENT') is None:
cls.ITER_ELEMENT = iter_element.__class__.__name__
abstract_page = page.__class__.__bases__[0]
parent_iter_element = getattr(abstract_page, cls.ITER_ELEMENT, None)
if not parent_iter_element:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment