-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411 from plone/erral-issue-410
provide an IContentListingObject adapter
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Provide an IContentListingObject adapter | ||
[erral] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from plone.app.contentlisting.interfaces import IContentListingObject | ||
from plone.app.contentlisting.realobject import RealContentListingObject | ||
from zope.interface import implementer | ||
|
||
|
||
@implementer(IContentListingObject) | ||
class OccurrenceContentListingObject(RealContentListingObject): | ||
|
||
def __getattr__(self, name): | ||
"""We'll override getattr so that we can defer name lookups to | ||
the real underlying objects without knowing the names of all | ||
attributes. | ||
""" | ||
if name.startswith("_"): | ||
raise AttributeError(name) | ||
obj = self.getObject() | ||
# we need to override the behavior of RealContentListingObject | ||
# because Occurrence objects rely on acquisition to show their title | ||
# and other attributes | ||
return getattr(obj, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters