Commit 568bf1b3 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[entities] Restore dc_ methods instead of __getattr__ proxy

In 8de62610cea2, a __getattr__ proxy was introduced to handle compatibility
with dc_* methods being called on entity instances instead of through the
IDublinCore adapter. Unfortunately, __getattr__ does not play well with
super() and since the latter is often used by, we here restore all dc_ methods
with an explicit proxy to the adapter. More verbose but should work.

Closes #17103999.

--HG--
branch : 3.25
parent 2b78124386b2
......@@ -98,15 +98,29 @@ class AnyEntity(Entity):
# meta data api ###########################################################
def __getattr__(self, name):
prefix = 'dc_'
if name.startswith(prefix):
# Proxy to IDublinCore adapter for bw compat.
adapted = self.cw_adapt_to('IDublinCore')
method = name[len(prefix):]
if hasattr(adapted, method):
return getattr(adapted, method)
raise AttributeError(name)
def dc_title(self):
return self.cw_adapt_to('IDublinCore').title()
def dc_long_title(self):
return self.cw_adapt_to('IDublinCore').long_title()
def dc_description(self, *args, **kwargs):
return self.cw_adapt_to('IDublinCore').description(*args, **kwargs)
def dc_authors(self):
return self.cw_adapt_to('IDublinCore').authors()
def dc_creator(self):
return self.cw_adapt_to('IDublinCore').creator()
def dc_date(self, *args, **kwargs):
return self.cw_adapt_to('IDublinCore').date(*args, **kwargs)
def dc_type(self, *args, **kwargs):
return self.cw_adapt_to('IDublinCore').type(*args, **kwargs)
def dc_language(self):
return self.cw_adapt_to('IDublinCore').language()
@property
def creator(self):
......
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