[Zope3-checkins] CVS: Products3/NewsSite/NewsItem - browser.py:1.2 configure.zcml:1.2 interfaces.py:1.2 news.py:1.2
Volker Bachschneider
vbachs@dzug.org
Tue, 25 Mar 2003 09:26:55 -0500
Update of /cvs-repository/Products3/NewsSite/NewsItem
In directory cvs.zope.org:/tmp/cvs-serv18729/NewsItem
Modified Files:
browser.py configure.zcml interfaces.py news.py
Log Message:
Changed to schema
=== Products3/NewsSite/NewsItem/browser.py 1.1 => 1.2 ===
--- Products3/NewsSite/NewsItem/browser.py:1.1 Tue Mar 25 07:52:50 2003
+++ Products3/NewsSite/NewsItem/browser.py Tue Mar 25 09:26:52 2003
@@ -1,43 +1,12 @@
-from zope.component import getAdapter
-from zope.app.event import publish
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.interfaces.container import IAdding
-from interfaces import INewsItemInfo, INewsItem, INewsItemAdd
+from interfaces import INewsItem
class NewsItemInfoView:
"""Provide an interface for viewing a news item
"""
- __used_for__ = INewsItemInfo
+ __used_for__ = INewsItem
def __init__(self, context, request):
self.context = context
self.request = request
-
-
-class NewsItemEditView:
- """Provide a user interface for editing a news item
- """
-
- # Assert that we can only be applied to INewsItem
- __used_for__ = INewsItem
-
- # action method
- def action(self, newsbody):
- "Edit a news item"
- self.context.update(newsbody)
- publish(self.context, ObjectModifiedEvent(self.context))
- self.request.response.redirect('.')
-
-class NewsItemAddView:
- """Provide a user interface for adding a news item
- """
-
- # Assert that we can only be applied to IAdding
- __used_for__ = IAdding
- # action method
- def action(self, newsbody):
- "Add a news item"
- getAdapter(self.context, INewsItemAdd).add(newsbody)
- self.request.response.redirect(self.context.nextURL())
=== Products3/NewsSite/NewsItem/configure.zcml 1.1 => 1.2 ===
--- Products3/NewsSite/NewsItem/configure.zcml:1.1 Tue Mar 25 07:52:50 2003
+++ Products3/NewsSite/NewsItem/configure.zcml Tue Mar 25 09:26:52 2003
@@ -1,4 +1,4 @@
-<zopeConfigure
+<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:browser='http://namespaces.zope.org/browser'>
@@ -10,58 +10,48 @@
<implements
interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
/>
- <factory
- id="zopeproducts.NewsItem"
+ <factory
+ id="zopeproducts.NewsSite.NewsItem"
permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" />
<require
permission="zope.View"
- interface=".interfaces.INewsItemInfo" />
+ interface=".interfaces.INewsItem" />
<require
permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems"
- attributes="update" />
+ set_schema=".interfaces.INewsItem" />
</content>
+<!--
<adapter
provides=".interfaces.INewsItemAdd"
for="zope.app.interfaces.container.IAdding"
factory=".news.NewsItemAdd"
/>
+-->
-<browser:addview
+<browser:addform
+ schema=".interfaces.INewsItem"
+ label="Add News Item"
+ content_factory=".news.NewsItem"
+ arguments="newsbody"
name="AddNewsItem"
menu="add_content" title="News Item"
- class=".browser.NewsItemAddView"
- permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems"
- >
-
- <browser:page name="add.html" template="add.pt" />
- <browser:page name="action.html" attribute="action" />
-</browser:addview>
-
-<browser:defaultView for=".interfaces.INewsItemInfo" name="info.html" />
-
+ permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" />
+
+<browser:editform
+ schema=".interfaces.INewsItem"
+ label="Change News Item"
+ name="edit.html"
+ menu="zmi_views" title="Edit"
+ permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems" />
+
<browser:page
- for=".interfaces.INewsItemInfo"
- name="info.html"
+ for=".interfaces.INewsItem"
+ name="index.html"
template="info.pt"
menu="zmi_views" title="View"
class=".browser.NewsItemInfoView"
- permission="zope.View"
- />
-
-<browser:pages
- for=".interfaces.INewsItem"
- class=".browser.NewsItemEditView"
- permission="zopeproducts.NewsSite.NewsItem.ManageNewsItems"
- >
-
- <browser:page
- name="edit.html"
- template="edit.pt"
- menu="zmi_views" title="Edit"
- />
- <browser:page name="editAction.html" attribute="action" />
-</browser:pages>
+ permission="zope.View" />
<browser:icon name="zmi_icon" for=".interfaces.INewsItem" file="newsitem_icon.gif" />
=== Products3/NewsSite/NewsItem/interfaces.py 1.1 => 1.2 ===
--- Products3/NewsSite/NewsItem/interfaces.py:1.1 Tue Mar 25 07:52:50 2003
+++ Products3/NewsSite/NewsItem/interfaces.py Tue Mar 25 09:26:52 2003
@@ -1,26 +1,7 @@
from zope.interface import Interface
+from zope.schema import Text
-class INewsItemInfo(Interface):
- "Provides access to basic news information."
-
- def newsbody():
- """Get the newsbody
- """
-
-class INewsItem(INewsItemInfo):
+class INewsItem(Interface):
"Provides the ability to change news information."
- def update(newsbody) :
- """Modifies news data
-
- 'None' values are ignored.
- """
-
-class INewsItemAdd(Interface):
- """Add context using IAdding objects
- """
-
- def add(newsbody):
- """Add a news initialized from the given arguments
- """
-
+ newsbody = Text(title=u"News Message")
=== Products3/NewsSite/NewsItem/news.py 1.1 => 1.2 ===
--- Products3/NewsSite/NewsItem/news.py:1.1 Tue Mar 25 07:52:50 2003
+++ Products3/NewsSite/NewsItem/news.py Tue Mar 25 09:26:52 2003
@@ -1,8 +1,5 @@
import persistence
-from interfaces import INewsItem, INewsItemInfo, INewsItemAdd
-from zope.app.interfaces.container import IAdding
-from zope.app.event import publish
-from zope.app.event.objectevent import ObjectCreatedEvent
+from interfaces import INewsItem
class NewsItem(persistence.Persistent):
"""News Item.
@@ -11,28 +8,5 @@
__implements__ = INewsItem
def __init__(self, newsbody=''):
- self.update(newsbody)
-
- def newsbody(self):
- return self._newsbody
-
- def update(self, newsbody=None):
- if newsbody is not None:
- self._newsbody = newsbody
-
-class NewsItemAdd:
- "Provide a user interface for adding a news item"
-
- # Assert that we can only be applied to IAdding
- __used_for__ = IAdding
-
- __implements__ = INewsItemAdd
-
- def __init__(self, context):
- self.context = context
-
- def add(self, newsbody):
- news_item = NewsItem()
- publish(self.context.context, ObjectCreatedEvent(news_item))
- news_item.update(newsbody)
- self.context.add(news_item)
+ self.newsbody=newsbody
+