forked from rochecompaan/upfront.simplereferencefield
jbeyers/upfront.simplereferencefield
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
simplereferencefield is an Archeteyps reference field implementation that stores the references directly on the object without indexing it in the reference_catalog. Create a document that references news. >>> self.loginAsPortalOwner() >>> self.portal.invokeFactory('Document', 'doc1') 'doc1' >>> doc = self.portal['doc1'] >>> doc.setRelatedItems(self.portal.news) >>> doc.reindexObject() >>> doc.getRelatedItems() [<ATFolder at /plone/news>] The document has a relationship. >>> doc.getRelationships() ['relatesTo'] Change relatedItems in the document's schema to be a SimpleReferenceField. >>> from Products.ATContentTypes.content.document import ATDocument >>> from upfront.simplereferencefield import SimpleReferenceField >>> ATDocument.schema['relatedItems'] = SimpleReferenceField( ... 'relatedItems', relationship='relatesTo', multiValued=1) >>> ATDocument.schema['relatedItems'].type 'simplereference' Create a document that references news. >>> self.portal.invokeFactory('Document', 'doc2') 'doc2' >>> doc = self.portal['doc2'] >>> doc.setRelatedItems(self.portal.news) >>> doc.reindexObject() >>> doc.getRelatedItems() [<ATFolder at /plone/news>] The document has no relationships. >>> doc.getRelationships() [] If we reference doc1 from doc2, doc1 will have doc2 set as back reference. >>> self.portal.doc2.setRelatedItems(self.portal.doc1) >>> self.portal.doc2.getRelatedItems() [<ATDocument at /plone/doc1>] >>> self.portal.doc1.getRelatedItems() [<ATDocument at /plone/doc2>] Back references are set by default but can be disabled. >>> ATDocument.schema['relatedItems'] = SimpleReferenceField( ... 'relatedItems', relationship='relatesTo', multiValued=1, ... set_backreference=False) >>> self.portal.invokeFactory('Document', 'doc3') 'doc3' >>> self.portal.doc3.setRelatedItems(self.portal.doc1) >>> self.portal.doc3.getRelatedItems() [<ATDocument at /plone/doc1>] >>> self.portal.doc1.getRelatedItems() [<ATDocument at /plone/doc2>]
About
simplereferencefield is an Archeteyps reference field implementation that stores the references directly on the object
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Python 100.0%