[Checkins] SVN: Grokstar/trunk/src/grokstar/ Use applyData instead of applyChanges

Jan-Wijbrand Kolman jw at infrae.com
Wed May 30 15:14:22 EDT 2007


Log message for revision 76003:
  Use applyData instead of applyChanges
  
  Use grok.Indexes.

Changed:
  U   Grokstar/trunk/src/grokstar/blog.py
  U   Grokstar/trunk/src/grokstar/entry.py

-=-
Modified: Grokstar/trunk/src/grokstar/blog.py
===================================================================
--- Grokstar/trunk/src/grokstar/blog.py	2007-05-30 19:04:59 UTC (rev 76002)
+++ Grokstar/trunk/src/grokstar/blog.py	2007-05-30 19:14:21 UTC (rev 76003)
@@ -2,31 +2,18 @@
 from datetime import datetime, timedelta
 
 from zope import schema
-from zope.app.intid import IntIds
-from zope.app.intid.interfaces import IIntIds
-from zope.app.catalog.catalog import Catalog
-from zope.app.catalog.interfaces import ICatalog
-from zope.app.catalog.field import FieldIndex
 
 from hurry.query.query import Query
 from hurry import query
 from hurry.workflow.interfaces import IWorkflowState
 
 import grok
+from grok import index
 
 from grokstar.interfaces import IEntry, PUBLISHED
 
-def setup_catalog(catalog):
-    catalog['published'] = FieldIndex('published', IEntry)
-    catalog['workflow_state'] = FieldIndex('getState', IWorkflowState, True)
-    catalog['workflow_id'] = FieldIndex('getId', IWorkflowState, True)
-    
-class Blog(grok.Container, grok.Site):
+class Blog(grok.Container, grok.Application):
 
-    grok.local_utility(IntIds, provides=IIntIds)
-    grok.local_utility(Catalog, provides=ICatalog, name='entry_catalog',
-                       setup=setup_catalog)
-    
     class fields:
         title = schema.TextLine(title=u'Title', default=u'')
         tagline = schema.TextLine(title=u'Tagline', default=u'')
@@ -35,6 +22,21 @@
         super(Blog, self).__init__()
         self['entries'] = Entries()
 
+class BlogIndexes(grok.Indexes):
+    grok.site(Blog)
+    grok.context(IEntry)
+    grok.name('entry_catalog')
+
+    published = Field(attribute='published')
+
+class BlogIndexes(grok.Indexes):
+    grok.site(Blog)
+    grok.context(IWorkflowState)
+    grok.name('entry_catalog')
+
+    workflow_state = Field(attribute='getState')
+    workflow_id = Field(attribute='getId')
+
 class Entries(grok.Container):
     pass
 
@@ -51,7 +53,7 @@
 
     @grok.action('Save changes')
     def edit(self, **data):
-        self.applyChanges(**data)
+        self.applyData(self.context, **data)
         self.redirect(self.url(self.context))
 
 class EntriesIndex(grok.View):

Modified: Grokstar/trunk/src/grokstar/entry.py
===================================================================
--- Grokstar/trunk/src/grokstar/entry.py	2007-05-30 19:04:59 UTC (rev 76002)
+++ Grokstar/trunk/src/grokstar/entry.py	2007-05-30 19:14:21 UTC (rev 76003)
@@ -20,7 +20,7 @@
         self.published = None
         self.summary = summary
         self.rightsinfo = rightsinfo
-        
+
 class RestructuredTextEntry(Entry):
     interface.implements(interfaces.IRestructuredTextEntry)
 
@@ -61,12 +61,12 @@
 
     @grok.action('Save changes')
     def edit(self, **data):
-        self.applyChanges(**data)
+        self.applyData(self.context, **data)
         self.redirect(self.url(self.context))
 
     @grok.action('Publish')
     def publish(self, **data):
-        self.applyChanges(**data)
+        self.applyData(self.context, **data)
         IWorkflowInfo(self.context).fireTransitionToward(interfaces.PUBLISHED)
         self.redirect(self.url(self.context))
 



More information about the Checkins mailing list