[z3-checkins] r42167 - z3/NudgeNudge/branches/indexes-refactoring/src/nudgenudge
philikon at codespeak.net
philikon at codespeak.net
Thu Apr 19 13:23:47 CEST 2007
Author: philikon
Date: Thu Apr 19 13:23:47 2007
New Revision: 42167
Modified:
z3/NudgeNudge/branches/indexes-refactoring/src/nudgenudge/app.py
Log:
Use grok.Indexes to define indexes. Sadly, zc.catalog's indexes aren't available
so we'll have to use the crummy field index.
Modified: z3/NudgeNudge/branches/indexes-refactoring/src/nudgenudge/app.py
==============================================================================
--- z3/NudgeNudge/branches/indexes-refactoring/src/nudgenudge/app.py (original)
+++ z3/NudgeNudge/branches/indexes-refactoring/src/nudgenudge/app.py Thu Apr 19 13:23:47 2007
@@ -1,4 +1,5 @@
import grok
+from grok import index
from zope import schema, component, interface
from zope.app.intid import IntIds
from zope.app.intid.interfaces import IIntIds
@@ -23,10 +24,6 @@
grok.define_permission('nudge.EditReview')
grok.define_permission('nudge.DeleteReview')
-def setup_catalog(catalog):
- catalog['package_name'] = ValueIndex('package_name', IReview, False)
- catalog['author'] = ValueIndex('author', IReview, False)
-
def setup_pau(pau):
pau['principals'] = PrincipalFolder('nudge.principals.')
pau.authenticatorPlugins = ('principals',)
@@ -41,14 +38,19 @@
return factory
class NudgeNudge(grok.Application, grok.Container):
- grok.local_utility(IntIds, IIntIds) # needed for the catalog
- grok.local_utility(Catalog, ICatalog, setup=setup_catalog)
grok.local_utility(PluggableAuthentication, IAuthentication,
setup=setup_pau)
grok.local_utility(role_factory(u'Nudge Reviewers'), IRole,
name='nudge.Reviewers',
name_in_container='nudge.Reviewers')
+class ReviewIndexes(grok.Indexes):
+ grok.application(NudgeNudge)
+ grok.context(IReview)
+
+ package_name = index.Field()
+ author = index.Field()
+
@grok.subscribe(NudgeNudge, grok.IObjectAddedEvent)
def grant_permissions(app, event):
role_manager = IRolePermissionManager(app)
@@ -60,7 +62,7 @@
self.results = []
if package:
catalog = component.getUtility(ICatalog)
- query = {'any_of': (package,)}
+ query = (package, package)
self.results = catalog.searchResults(package_name=query)
class CreateReview(grok.AddForm):
@@ -72,7 +74,7 @@
@grok.action('Create')
def create(self, **kw):
r = Review()
- self.applyData(r, **kw)
+ self.applyChanges(r, **kw)
base = name = kw['package_name'] + '-' + kw['version']
count = 0
More information about the z3-checkins
mailing list