Skip to content

Instantly share code, notes, and snippets.

View jaroel's full-sized avatar

Roel Bruggink jaroel

View GitHub Profile
@jaroel
jaroel / gist:5345392
Last active December 16, 2015 00:09
Parameterised dynamic vocabulary. Shows content of catalog using query with object_provides. Pass in the interface in the schema.
Definition:
===========
from zope.schema.interfaces import IContextSourceBinder, IBaseVocabulary
class CatalogObjectProvidesSource(object):
grok.implements(IContextSourceBinder, IBaseVocabulary)
def __init__(self, interface):
self.interface = interface
@jaroel
jaroel / gist:1688278
Created January 27, 2012 10:59
Count words in Plone html
catalog = context.portal_catalog
lexicon = catalog.htmlwordsplitter_lexicon
brains = catalog(Language='nl', portal_type='CoolPage')
words = dict(Title=0, Description=0, getText=0)
for brain in brains:
ob = brain.getObject()
words['Title'] = ob.Title().split()
words['Description'] = ob.Description().split()
words['getText'] = lexicon.parseTerms(ob.getText())
[buildout]
extends =
http://x.aclark.net/plone/4.1.x/develop.cfg
http://good-py.appspot.com/release/dexterity/1.1
auto-checkout =
collective.z3cform.datagridfield
plone.app.relationfield
collective.z3cform.datagridfield_demo