cornerstone.soup Lighning Talk on Plone Conference 2009
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

cornerstone.soup Lighning Talk on Plone Conference 2009

on

  • 1,180 views

shows how to use cornerstone.soup, a lightweight mass-data storage inside zodb for zope2 and plone

shows how to use cornerstone.soup, a lightweight mass-data storage inside zodb for zope2 and plone

Statistics

Views

Total Views
1,180
Views on SlideShare
1,179
Embed Views
1

Actions

Likes
0
Downloads
7
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

cornerstone.soup Lighning Talk on Plone Conference 2009 Presentation Transcript

  • 1. Plone Conference 2009 Budapest Lightning Talk cornerstone.soup isolated container for queryable records Jens Klein <jens@bluedynamics.com> 2010-10-29 Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 2. Use-Cases Need Container for many entities (mass-data) of non-CMSish content, like: – Votes, – Data from a Poll, – Orders in a Webshop, – measuring data, – (fill in your use-case here) tested with Plone 3.3 Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 3. Soup Characteristics ● isolated: all in one persistent local utility; ● stores generic „Records“: – persistent items – with attributes passed in at construction time as keyword arguments. ● has its own local index (ZopeToolKit); ● fetches items by query. Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 4. Recipe Cook your own Soup Heat editor in a large soucepan, subclass the soup 1 object and give it an appropriate id: >>> from cornerstone.soup import Soup >>> class MySoup(Soup): ... id = u'mysoup' Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 5. Recipe Cook your own Soup Provide a Catalog Factory and cook for 2-3 minutes, until 2 softened but not colored. >>> from zope.interface import implements >>> from zope.catalog.catalog import Catalog >>> from zope.catalog.field import FieldIndex >>> from cornerstone.soup.interfaces import ICatalogFactory >>> class MyCatalogFactory(object): ... implements(ICatalogFactory) ... ... def __call__(self): ... catalog = Catalog() ... catalog[u'name'] = FieldIndex(field_name='name', ... field_callable=False) ... return catalog Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 6. Recipe Cook your own Soup Add one utility registered under the same name as 3 the soup-id, stirring, for 20 seconds: <utility name="mysoup" factory=".mymodule.MyCatalogFactory" provides="cornerstone.soup.interfaces.ICatalogFactory" /> Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 7. Recipe Cook your own Soup 4 Add two local utilities to componentregistry.xml registered under the same name as the soup-id, and bring to boil. <utilities> <utility name="mysoup" factory="mymodule.MySoup" interface="cornerstone.soup.interfaces.ISoup" /> <utility name="mysoup" factory="five.intid.intid.OFSIntIds" interface="zope.app.intid.interfaces.IIntIds" /> </utilities> Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 8. Recipe Cook your own Soup Start your Plone, turn heat to low, cover and 5 simmer for some minutes. Go to portal_setup and import your packages GenericSetup profile. Season and add a little more data if desired. >>> from zope.component import getUtility >>> from cornerstone.soup.interfaces import ISoup >>> soup = getUtility(ISoup, name=u'mysoup') >>> from cornerstone.soup import Record >>> rec = Record(name=u'rec1') >>> soup.add(rec) >>> rec = Record(name=u'rec2') >>> soup.add(rec) Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 9. Enjoy your soup bon appetit! Query data: >>> soup.query(name=u'rec1') [<Record at /.../record-0>] >>> soup.query(name=u'rec2') [<Record at /.../record-1>] Modify data: >>> rec.data['name'] = u'rec1' >>> soup.reindex([rec]) >>> soup.query(name=u'rec1') [<Record at /.../record-0>, <Record at /.../record-1>] Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz
  • 10. Ingredients and complete recipe http://pypi.python.org/pypi/cornerstone.soup Creative Commons Namensnennung- Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz