Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new connections attribute to Places JSON #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Products/PleiadesEntity/browser/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
i18n_domain="Products.PleiadesEntity"
>

<adapter
for="Products.PleiadesEntity.content.interfaces.IConnection"
factory=".connection.ConnectionExportAdapter" />

<adapter
for="Products.CMFCore.interfaces.IContentish"
factory=".ContentExportAdapter" />
Expand Down
32 changes: 32 additions & 0 deletions Products/PleiadesEntity/browser/adapters/connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from Products.PleiadesEntity.time import to_ad
from . import ContentExportAdapter
from . import PlaceSubObjectExportAdapter
from . import TemporalExportAdapter
from . import WorkExportAdapter
from . import archetypes_getter
from . import get_export_adapter
from . import memoize_all_methods


@memoize_all_methods
class ConnectionExportAdapter(
ContentExportAdapter,
WorkExportAdapter,
TemporalExportAdapter,
PlaceSubObjectExportAdapter):

associationCertainty = archetypes_getter('associationCertainty')
details = archetypes_getter('text')

connectionType = archetypes_getter('relationshipType')

def connectionTypeURI(self):
return "{}/relationship-types/{}".format(
self.context.restrictedTraverse('vocabularies').aq_inner.absolute_url(),
self.context.getRelationshipType()
)

def connectsTo(self):
target = self.context.getConnection()
adapter = get_export_adapter(target)
return adapter.uri()
2 changes: 2 additions & 0 deletions Products/PleiadesEntity/browser/adapters/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def connectsWith(self):
for id in (self._connectsWith() + self._hasConnectionsWith())
]

connections = export_children('Connection')

def reprPoint(self):
value = self.brain.reprPt
if not value:
Expand Down