SlideShare a Scribd company logo
1 of 19
Download to read offline
Relationship Building
Deļ¬ning and Querying Complex Relationships
          Between Your Content

              Alec P. Mitchell
Existing Tools

ā€¢ Archetypes Reference Engine
ā€¢ External SQL database
ā€¢ zc.relationship + plone.relations
ā€¢ ???
Beneļ¬ts of AT
          References
ā€¢ Can relate any AT content to any other AT
  content.
ā€¢ There are nice widgets available to
  manipulate relationships.
ā€¢ Uses the familiar ZCatalog internally.
ā€¢ Relationships can provide complex
  behaviors.
Disadvantages of AT
       References
ā€¢ Requires mixin base classes. Essentially only
  works with AT content.
ā€¢ References are intrinsic to their source, and
  generally deļ¬ned as part of the content
  schema.
ā€¢ General purpose ZCatalog not entirely
  optimized for relationship queries.
ā€¢ API tends is somewhat inconsistent, and test
  coverage is sub-optimal.
Beneļ¬ts of an RDBMS-
   based Solution
ā€¢ Can support arbitrarily complex
  relationships and queries.
ā€¢ Can be performance tuned for speciļ¬c use-
  cases.
ā€¢ Can be used to relate anything to anything
  else.
Disadvantages of an
RDBMS-based Solution

ā€¢ Entirely DIY
ā€¢ Requires an external database
ā€¢ Need to create some 1-to-1 mapping
  between RDBMS keys and ZODB content.
What is zc.relationship
ā€¢ A low-level ZODB index for querying
  relationships
 ā€¢ Highly optimized for simple relationship
    queries across large data-sets.
 ā€¢ Default conļ¬guration allows relationships
    between arbitrary persistent objects.
 ā€¢ Index can be conļ¬gured to index complex
    relationships, which may include non-
    ZODB objects.
 ā€¢ Provides transitive searches.
What is plone.relations
ā€¢ A local utility built on zc.relationship, which
  is applicable to a wide variety of relationship
  models.
ā€¢ A relationship class that models many-to-
  many content relationships.
ā€¢ Some optional aspects of the relationship
  are also indexed:
  ā€¢ Relationship Type
  ā€¢ Relationship State
  ā€¢ Relationship Context
What is
    plone.app.relations
ā€¢ A content-centric API for deļ¬ning and
  querying relationships:
     src = IRelationshipSource(ob)
     src.createRelationship(target=ob2)
     src.getTargets()
     ...

ā€¢ A set of optional adapters and subscribers
 ā€¢ DCWorkļ¬‚ow for relationships
 ā€¢ ā€œHoldingā€ relationships
 ā€¢ Relationships which are copied when their
    source is copied.
Relationship Sources

ā€¢ IRelationshipSource
 ā€¢ Create (createRelationship), supports
    multiple targets
 ā€¢ Query (getTargets, isLinked,
    getRelationshipChains, getRelatonships)
 ā€¢ Modify (deleteRelationship,
    getRelationships)
Relationship Targets
ā€¢ IRelationshipTarget
 ā€¢ Same query methods and parameters as
    IRelationshipSource + getSources
ā€¢ ISymmetricRelation
 ā€¢ Query (isLinked, getRelationships,
    getRelations)
 ā€¢ No transitivity, for now
Brief Code Example
>>> class IFriendship(IDCWorkflowableRelationship):
...     ā€œā€ā€A friendshipā€ā€ā€
>>> source = IRelationshipSource(ob1)
>>> rel = source.createRelationship(ob2, relation=ā€™friendā€™,
...                                 interfaces=(IFriendship,))
>>> list(source.getRelationships(relation=ā€™friendā€™))
[<Relationship ā€˜friendā€™ from (<Demo ob1>,) to (<Demo ob2>,)]
>>> list(rel.targets), list(rel.sources)
([<Demo ob2>], [<Demo ob1>])
>>> list(source.getTargets())
[<Demo ob2>]
>>> list(source.getRelationshipChains(target=ob2, maxDepth=5))
[(<Relationship ā€˜friendā€™ from (<Demo ob1>,) to (<Demo ob2>,)>,)]
>>> target = IRelationshipTarget(ob2)
>>> list(target.getSources(relation-ā€™friendā€™))
[<Demo ob1>]
>>> target.isLinked(source=ob1)
True
>>> list(ISymmetricRelation(ob1).getRelations())
[<Demo ob2>]
>>> list(ISymmetricRelation(ob2).getRelations())
[<Demo ob1>]
>>> wf_rel = IDCWorkflowRelation(rel)
>>> wf_rel.workflow_id = ā€˜friend_workflowā€™
>>> wf.doAction(ā€˜approveā€™)
>>> wf.state
ā€˜approvedā€™
What Can You Do With It?
 ā€¢ Model any non-container relationships you
   might need.
  ā€¢ Social Networking (user   user,
     user group/workspace)
  ā€¢ User Favorites (user content)
  ā€¢ Placeless Content
  ā€¢ Taxonomies or Complex Vocabularies
  ā€¢ Related Content
What Have I Done With It?
 ā€¢ The Daily Reel (http://www.thedailyreel.com)
  ā€¢ Social network for online video creators
    ā€¢ Contacts (user relationships with approval)
    ā€¢ Crews (discussion groups)
    ā€¢ Videos which ā€œbelongā€ to crews and users
       (placeless content)
    ā€¢ Favorite Content
Brief UI Demo
Shortcomings
ā€¢ Relationships are inherently asymmetric,
  with sources and targets on unequal footing.
ā€¢ Relationships are unordered
ā€¢ Requires persistent sources/targets/
  contexts.
ā€¢ Uses IntIds: fast but limits the number of
  indexed objects to sys.maxint.
ā€¢ No user-space tools/UI, yet.
When to Use
        Something Else
ā€¢ Efļ¬cient sorting on a large result set of
  relationships.
ā€¢ Complex queries. Currently thereā€™s only
  ā€˜==ā€™ (for source/target, state, context)
ā€¢ Non-ZODB objects
ā€¢ Donā€™t have time to make your own UI (stick
  with AT for now)
The Future?

ā€¢ Support for explicit ordering of relationships
ā€¢ API providing permission based ļ¬ltering
ā€¢ UI (schema ļ¬eld, formlib widget)
ā€¢ Move general code downstream into
  zc.relationship
Thank You!
ā€¢ Special thanks to
 ā€¢ Balazs Ree
 ā€¢ Gary Poster and Zope Corporation
 ā€¢ Whit Morriss
 ā€¢ Ramon Navarro Bosch
 ā€¢ The Daily Reel
 ā€¢ Vincenzo and the conference organizers
ā€¢ And now we sprint!!

More Related Content

Similar to Alec Mitchell Relationship Building Defining And Querying Complex Relationships Between Your Content

SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsMike Broberg
Ā 
Jsp + My Sql
Jsp + My SqlJsp + My Sql
Jsp + My SqlAshwin K
Ā 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBApaichon Punopas
Ā 
IT6701 Information Management - Unit I
IT6701 Information Management - Unit I  IT6701 Information Management - Unit I
IT6701 Information Management - Unit I pkaviya
Ā 
Action-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCAction-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCPaul Jones
Ā 
2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1Wolfram Arnold
Ā 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptkingkolju
Ā 
Getting the Most out of Linkscape
Getting the Most out of LinkscapeGetting the Most out of Linkscape
Getting the Most out of LinkscapeNick Gerner
Ā 
jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxssuser8878c1
Ā 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerPaul Jones
Ā 
Connect2014 Show104: Practical Java
Connect2014 Show104: Practical JavaConnect2014 Show104: Practical Java
Connect2014 Show104: Practical Javapanagenda
Ā 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principleelliando dias
Ā 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityBill Buchan
Ā 
Neo4j Presentation
Neo4j PresentationNeo4j Presentation
Neo4j PresentationMax De Marzi
Ā 
Thinking about graphs
Thinking about graphsThinking about graphs
Thinking about graphsNeo4j
Ā 
App301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent LibApp301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent Libmcgurk
Ā 
Instance Matching
Instance Matching Instance Matching
Instance Matching Robert Isele
Ā 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
Ā 
Semantika Introduction
Semantika IntroductionSemantika Introduction
Semantika IntroductionJosef Hardi
Ā 

Similar to Alec Mitchell Relationship Building Defining And Querying Complex Relationships Between Your Content (20)

SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 Questions
Ā 
Jsp + My Sql
Jsp + My SqlJsp + My Sql
Jsp + My Sql
Ā 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDB
Ā 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Ā 
IT6701 Information Management - Unit I
IT6701 Information Management - Unit I  IT6701 Information Management - Unit I
IT6701 Information Management - Unit I
Ā 
Action-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCAction-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVC
Ā 
2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1
Ā 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
Ā 
Getting the Most out of Linkscape
Getting the Most out of LinkscapeGetting the Most out of Linkscape
Getting the Most out of Linkscape
Ā 
jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptx
Ā 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Ā 
Connect2014 Show104: Practical Java
Connect2014 Show104: Practical JavaConnect2014 Show104: Practical Java
Connect2014 Show104: Practical Java
Ā 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principle
Ā 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database Connectivity
Ā 
Neo4j Presentation
Neo4j PresentationNeo4j Presentation
Neo4j Presentation
Ā 
Thinking about graphs
Thinking about graphsThinking about graphs
Thinking about graphs
Ā 
App301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent LibApp301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent Lib
Ā 
Instance Matching
Instance Matching Instance Matching
Instance Matching
Ā 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
Ā 
Semantika Introduction
Semantika IntroductionSemantika Introduction
Semantika Introduction
Ā 

More from Vincenzo Barone

Sally Kleinfeldt - Plone Application Development Patterns
Sally Kleinfeldt - Plone Application Development PatternsSally Kleinfeldt - Plone Application Development Patterns
Sally Kleinfeldt - Plone Application Development PatternsVincenzo Barone
Ā 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
Ā 
ItalianSkin: an improvement in the accessibility of the Plone interface in or...
ItalianSkin: an improvement in the accessibility of the Plone interface in or...ItalianSkin: an improvement in the accessibility of the Plone interface in or...
ItalianSkin: an improvement in the accessibility of the Plone interface in or...Vincenzo Barone
Ā 
How to market Plone the Web2.0 way
How to market Plone the Web2.0 wayHow to market Plone the Web2.0 way
How to market Plone the Web2.0 wayVincenzo Barone
Ā 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)Vincenzo Barone
Ā 
Wichert Akkerman Plone Deployment Practices The Plone.Org Setup
Wichert Akkerman   Plone Deployment Practices   The Plone.Org SetupWichert Akkerman   Plone Deployment Practices   The Plone.Org Setup
Wichert Akkerman Plone Deployment Practices The Plone.Org SetupVincenzo Barone
Ā 
Philipp Von Weitershausen Untested Code Is Broken Code
Philipp Von Weitershausen   Untested Code Is Broken CodePhilipp Von Weitershausen   Untested Code Is Broken Code
Philipp Von Weitershausen Untested Code Is Broken CodeVincenzo Barone
Ā 
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...Duco Dokter - Plone for the enterprise market: technical musing on caching, C...
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...Vincenzo Barone
Ā 
Rocky Burt Subtyping Unleashed
Rocky Burt   Subtyping UnleashedRocky Burt   Subtyping Unleashed
Rocky Burt Subtyping UnleashedVincenzo Barone
Ā 
Wageindicator Foundation: a Case Study
Wageindicator Foundation: a Case StudyWageindicator Foundation: a Case Study
Wageindicator Foundation: a Case StudyVincenzo Barone
Ā 
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentTom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentVincenzo Barone
Ā 
Xavier Heymans Plone Gov Plone In The Public Sector. Panel Presenting The...
Xavier Heymans   Plone Gov   Plone In The Public Sector. Panel Presenting The...Xavier Heymans   Plone Gov   Plone In The Public Sector. Panel Presenting The...
Xavier Heymans Plone Gov Plone In The Public Sector. Panel Presenting The...Vincenzo Barone
Ā 
Brent Lambert Plone In Education A Case Study Of The Use Of Plone And Educa...
Brent Lambert   Plone In Education A Case Study Of The Use Of Plone And Educa...Brent Lambert   Plone In Education A Case Study Of The Use Of Plone And Educa...
Brent Lambert Plone In Education A Case Study Of The Use Of Plone And Educa...Vincenzo Barone
Ā 
Wichert Akkerman - Plone.Org Infrastructure
Wichert Akkerman - Plone.Org InfrastructureWichert Akkerman - Plone.Org Infrastructure
Wichert Akkerman - Plone.Org InfrastructureVincenzo Barone
Ā 
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...Vincenzo Barone
Ā 
Denis Mishunov Making Plone Theme 10 Most Wanted Tips
Denis Mishunov   Making Plone Theme   10 Most Wanted Tips Denis Mishunov   Making Plone Theme   10 Most Wanted Tips
Denis Mishunov Making Plone Theme 10 Most Wanted Tips Vincenzo Barone
Ā 
Duncan Booth Kupu, Past Present And Future
Duncan Booth   Kupu, Past Present And FutureDuncan Booth   Kupu, Past Present And Future
Duncan Booth Kupu, Past Present And FutureVincenzo Barone
Ā 
Jeroen Vloothuis Bend Kss To Your Will
Jeroen Vloothuis   Bend Kss To Your WillJeroen Vloothuis   Bend Kss To Your Will
Jeroen Vloothuis Bend Kss To Your WillVincenzo Barone
Ā 
Jared Whitlock Open Source In The Enterprise Plone @ Novell
Jared Whitlock   Open Source In The Enterprise    Plone @ NovellJared Whitlock   Open Source In The Enterprise    Plone @ Novell
Jared Whitlock Open Source In The Enterprise Plone @ NovellVincenzo Barone
Ā 
Paul Everitt Community And Foundation Plones Past, Present, Future
Paul Everitt   Community And Foundation   Plones Past, Present, Future Paul Everitt   Community And Foundation   Plones Past, Present, Future
Paul Everitt Community And Foundation Plones Past, Present, Future Vincenzo Barone
Ā 

More from Vincenzo Barone (20)

Sally Kleinfeldt - Plone Application Development Patterns
Sally Kleinfeldt - Plone Application Development PatternsSally Kleinfeldt - Plone Application Development Patterns
Sally Kleinfeldt - Plone Application Development Patterns
Ā 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
Ā 
ItalianSkin: an improvement in the accessibility of the Plone interface in or...
ItalianSkin: an improvement in the accessibility of the Plone interface in or...ItalianSkin: an improvement in the accessibility of the Plone interface in or...
ItalianSkin: an improvement in the accessibility of the Plone interface in or...
Ā 
How to market Plone the Web2.0 way
How to market Plone the Web2.0 wayHow to market Plone the Web2.0 way
How to market Plone the Web2.0 way
Ā 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Ā 
Wichert Akkerman Plone Deployment Practices The Plone.Org Setup
Wichert Akkerman   Plone Deployment Practices   The Plone.Org SetupWichert Akkerman   Plone Deployment Practices   The Plone.Org Setup
Wichert Akkerman Plone Deployment Practices The Plone.Org Setup
Ā 
Philipp Von Weitershausen Untested Code Is Broken Code
Philipp Von Weitershausen   Untested Code Is Broken CodePhilipp Von Weitershausen   Untested Code Is Broken Code
Philipp Von Weitershausen Untested Code Is Broken Code
Ā 
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...Duco Dokter - Plone for the enterprise market: technical musing on caching, C...
Duco Dokter - Plone for the enterprise market: technical musing on caching, C...
Ā 
Rocky Burt Subtyping Unleashed
Rocky Burt   Subtyping UnleashedRocky Burt   Subtyping Unleashed
Rocky Burt Subtyping Unleashed
Ā 
Wageindicator Foundation: a Case Study
Wageindicator Foundation: a Case StudyWageindicator Foundation: a Case Study
Wageindicator Foundation: a Case Study
Ā 
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentTom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Ā 
Xavier Heymans Plone Gov Plone In The Public Sector. Panel Presenting The...
Xavier Heymans   Plone Gov   Plone In The Public Sector. Panel Presenting The...Xavier Heymans   Plone Gov   Plone In The Public Sector. Panel Presenting The...
Xavier Heymans Plone Gov Plone In The Public Sector. Panel Presenting The...
Ā 
Brent Lambert Plone In Education A Case Study Of The Use Of Plone And Educa...
Brent Lambert   Plone In Education A Case Study Of The Use Of Plone And Educa...Brent Lambert   Plone In Education A Case Study Of The Use Of Plone And Educa...
Brent Lambert Plone In Education A Case Study Of The Use Of Plone And Educa...
Ā 
Wichert Akkerman - Plone.Org Infrastructure
Wichert Akkerman - Plone.Org InfrastructureWichert Akkerman - Plone.Org Infrastructure
Wichert Akkerman - Plone.Org Infrastructure
Ā 
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Ā 
Denis Mishunov Making Plone Theme 10 Most Wanted Tips
Denis Mishunov   Making Plone Theme   10 Most Wanted Tips Denis Mishunov   Making Plone Theme   10 Most Wanted Tips
Denis Mishunov Making Plone Theme 10 Most Wanted Tips
Ā 
Duncan Booth Kupu, Past Present And Future
Duncan Booth   Kupu, Past Present And FutureDuncan Booth   Kupu, Past Present And Future
Duncan Booth Kupu, Past Present And Future
Ā 
Jeroen Vloothuis Bend Kss To Your Will
Jeroen Vloothuis   Bend Kss To Your WillJeroen Vloothuis   Bend Kss To Your Will
Jeroen Vloothuis Bend Kss To Your Will
Ā 
Jared Whitlock Open Source In The Enterprise Plone @ Novell
Jared Whitlock   Open Source In The Enterprise    Plone @ NovellJared Whitlock   Open Source In The Enterprise    Plone @ Novell
Jared Whitlock Open Source In The Enterprise Plone @ Novell
Ā 
Paul Everitt Community And Foundation Plones Past, Present, Future
Paul Everitt   Community And Foundation   Plones Past, Present, Future Paul Everitt   Community And Foundation   Plones Past, Present, Future
Paul Everitt Community And Foundation Plones Past, Present, Future
Ā 

Recently uploaded

Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
Ā 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
Ā 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Trucks in Minnesota
Ā 
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
Ā 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
Ā 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
Ā 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfAmzadHosen3
Ā 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
Ā 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
Ā 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
Ā 
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangaloreamitlee9823
Ā 
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...amitlee9823
Ā 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
Ā 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
Ā 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
Ā 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
Ā 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
Ā 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
Ā 

Recently uploaded (20)

Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
Ā 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
Ā 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
Ā 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Ā 
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow šŸ’‹ Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Ā 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
Ā 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
Ā 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
Ā 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
Ā 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Ā 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
Ā 
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Ā 
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...
Call Girls Electronic City Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Servi...
Ā 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
Ā 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
Ā 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Ā 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
Ā 
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Ā 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Ā 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ā 

Alec Mitchell Relationship Building Defining And Querying Complex Relationships Between Your Content

  • 1. Relationship Building Deļ¬ning and Querying Complex Relationships Between Your Content Alec P. Mitchell
  • 2. Existing Tools ā€¢ Archetypes Reference Engine ā€¢ External SQL database ā€¢ zc.relationship + plone.relations ā€¢ ???
  • 3. Beneļ¬ts of AT References ā€¢ Can relate any AT content to any other AT content. ā€¢ There are nice widgets available to manipulate relationships. ā€¢ Uses the familiar ZCatalog internally. ā€¢ Relationships can provide complex behaviors.
  • 4. Disadvantages of AT References ā€¢ Requires mixin base classes. Essentially only works with AT content. ā€¢ References are intrinsic to their source, and generally deļ¬ned as part of the content schema. ā€¢ General purpose ZCatalog not entirely optimized for relationship queries. ā€¢ API tends is somewhat inconsistent, and test coverage is sub-optimal.
  • 5. Beneļ¬ts of an RDBMS- based Solution ā€¢ Can support arbitrarily complex relationships and queries. ā€¢ Can be performance tuned for speciļ¬c use- cases. ā€¢ Can be used to relate anything to anything else.
  • 6. Disadvantages of an RDBMS-based Solution ā€¢ Entirely DIY ā€¢ Requires an external database ā€¢ Need to create some 1-to-1 mapping between RDBMS keys and ZODB content.
  • 7. What is zc.relationship ā€¢ A low-level ZODB index for querying relationships ā€¢ Highly optimized for simple relationship queries across large data-sets. ā€¢ Default conļ¬guration allows relationships between arbitrary persistent objects. ā€¢ Index can be conļ¬gured to index complex relationships, which may include non- ZODB objects. ā€¢ Provides transitive searches.
  • 8. What is plone.relations ā€¢ A local utility built on zc.relationship, which is applicable to a wide variety of relationship models. ā€¢ A relationship class that models many-to- many content relationships. ā€¢ Some optional aspects of the relationship are also indexed: ā€¢ Relationship Type ā€¢ Relationship State ā€¢ Relationship Context
  • 9. What is plone.app.relations ā€¢ A content-centric API for deļ¬ning and querying relationships: src = IRelationshipSource(ob) src.createRelationship(target=ob2) src.getTargets() ... ā€¢ A set of optional adapters and subscribers ā€¢ DCWorkļ¬‚ow for relationships ā€¢ ā€œHoldingā€ relationships ā€¢ Relationships which are copied when their source is copied.
  • 10. Relationship Sources ā€¢ IRelationshipSource ā€¢ Create (createRelationship), supports multiple targets ā€¢ Query (getTargets, isLinked, getRelationshipChains, getRelatonships) ā€¢ Modify (deleteRelationship, getRelationships)
  • 11. Relationship Targets ā€¢ IRelationshipTarget ā€¢ Same query methods and parameters as IRelationshipSource + getSources ā€¢ ISymmetricRelation ā€¢ Query (isLinked, getRelationships, getRelations) ā€¢ No transitivity, for now
  • 12. Brief Code Example >>> class IFriendship(IDCWorkflowableRelationship): ... ā€œā€ā€A friendshipā€ā€ā€ >>> source = IRelationshipSource(ob1) >>> rel = source.createRelationship(ob2, relation=ā€™friendā€™, ... interfaces=(IFriendship,)) >>> list(source.getRelationships(relation=ā€™friendā€™)) [<Relationship ā€˜friendā€™ from (<Demo ob1>,) to (<Demo ob2>,)] >>> list(rel.targets), list(rel.sources) ([<Demo ob2>], [<Demo ob1>]) >>> list(source.getTargets()) [<Demo ob2>] >>> list(source.getRelationshipChains(target=ob2, maxDepth=5)) [(<Relationship ā€˜friendā€™ from (<Demo ob1>,) to (<Demo ob2>,)>,)] >>> target = IRelationshipTarget(ob2) >>> list(target.getSources(relation-ā€™friendā€™)) [<Demo ob1>] >>> target.isLinked(source=ob1) True >>> list(ISymmetricRelation(ob1).getRelations()) [<Demo ob2>] >>> list(ISymmetricRelation(ob2).getRelations()) [<Demo ob1>] >>> wf_rel = IDCWorkflowRelation(rel) >>> wf_rel.workflow_id = ā€˜friend_workflowā€™ >>> wf.doAction(ā€˜approveā€™) >>> wf.state ā€˜approvedā€™
  • 13. What Can You Do With It? ā€¢ Model any non-container relationships you might need. ā€¢ Social Networking (user user, user group/workspace) ā€¢ User Favorites (user content) ā€¢ Placeless Content ā€¢ Taxonomies or Complex Vocabularies ā€¢ Related Content
  • 14. What Have I Done With It? ā€¢ The Daily Reel (http://www.thedailyreel.com) ā€¢ Social network for online video creators ā€¢ Contacts (user relationships with approval) ā€¢ Crews (discussion groups) ā€¢ Videos which ā€œbelongā€ to crews and users (placeless content) ā€¢ Favorite Content
  • 16. Shortcomings ā€¢ Relationships are inherently asymmetric, with sources and targets on unequal footing. ā€¢ Relationships are unordered ā€¢ Requires persistent sources/targets/ contexts. ā€¢ Uses IntIds: fast but limits the number of indexed objects to sys.maxint. ā€¢ No user-space tools/UI, yet.
  • 17. When to Use Something Else ā€¢ Efļ¬cient sorting on a large result set of relationships. ā€¢ Complex queries. Currently thereā€™s only ā€˜==ā€™ (for source/target, state, context) ā€¢ Non-ZODB objects ā€¢ Donā€™t have time to make your own UI (stick with AT for now)
  • 18. The Future? ā€¢ Support for explicit ordering of relationships ā€¢ API providing permission based ļ¬ltering ā€¢ UI (schema ļ¬eld, formlib widget) ā€¢ Move general code downstream into zc.relationship
  • 19. Thank You! ā€¢ Special thanks to ā€¢ Balazs Ree ā€¢ Gary Poster and Zope Corporation ā€¢ Whit Morriss ā€¢ Ramon Navarro Bosch ā€¢ The Daily Reel ā€¢ Vincenzo and the conference organizers ā€¢ And now we sprint!!