[Zope3-checkins] CVS: Products3/NewsSite/NewsItem - browser.py:1.8 configure.zcml:1.11 info.pt:1.9 interfaces.py:1.7 news.py:1.7

Yvo Schubbe schubbe@web.de
Thu, 27 Mar 2003 13:05:04 -0500


Update of /cvs-repository/Products3/NewsSite/NewsItem
In directory cvs.zope.org:/tmp/cvs-serv20063/NewsItem

Modified Files:
	browser.py configure.zcml info.pt interfaces.py news.py 
Log Message:
new add/editform code for NewsItem (has problem with absolut_url -> not showing the 
zmi_views correctly, url has "(adapted)" in the path)
we need to make zope/app/form/utility.py and zope/app/browser/form/add.py and editview.py
adapter aware somehow!!


=== Products3/NewsSite/NewsItem/browser.py 1.7 => 1.8 ===
--- Products3/NewsSite/NewsItem/browser.py:1.7	Thu Mar 27 08:40:53 2003
+++ Products3/NewsSite/NewsItem/browser.py	Thu Mar 27 13:05:03 2003
@@ -35,21 +35,21 @@
     def getCreator(self):
         users = getAdapter(self.context, ICMFDublinCore).Creator()
         service = getService(self.context, servicenames.Authentication)
-        members = []	
-	for user in users:
-	   principal = None
-	   username = None
-	   try:	   
+        members = []        
+        for user in users:
+           principal = None
+           username = None
+           try:           
                principal = service.getPrincipal(user)
                username += getAdapter(principal, IMember).realname
            except NotFoundError:
                if principal:
-	         username = principal.getTitle()
-	       if not username:
-	         username = user
-	   if username: 
-	       members.append(username)
-	   
+                 username = principal.getTitle()
+               if not username:
+                 username = user
+           if username: 
+               members.append(username)
+           
 
         return tuple(members)
 


=== Products3/NewsSite/NewsItem/configure.zcml 1.10 => 1.11 ===
--- Products3/NewsSite/NewsItem/configure.zcml:1.10	Thu Mar 27 12:42:42 2003
+++ Products3/NewsSite/NewsItem/configure.zcml	Thu Mar 27 13:05:03 2003
@@ -25,28 +25,37 @@
       />
 </content>
 
+<adapter
+    provides="zopeproducts.NewsSite.NewsItem.interfaces.INewsItemForm"
+    for="zopeproducts.NewsSite.NewsItem.interfaces.INewsItem"
+    factory="zopeproducts.NewsSite.NewsItem.news.NewsItemAttributesAdapter"
+    />
+
 <browser:addform
     name="AddNewsItem"
-    schema=".interfaces.INewsItem"
+    schema=".interfaces.INewsItemForm"
     label="Add News Item"
     content_factory=".news.NewsItem"
-    arguments="newsbody"
     permission="zopeproducts.NewsSite.CreateNewsItems"
+    fields="title teaser body effective expires"
     menu="add_news"
     title="News Item"
     template="../addform.pt"
     />
-
+    
 <browser:editform
+    schema=".interfaces.INewsItemForm"
+    label="Change News Item"
     name="edit.html"
-    schema=".interfaces.INewsItem"
+    for="zopeproducts.NewsSite.NewsItem.interfaces.INewsItem"
     template="../editform.pt"
     label="Change News Item"
     permission="zopeproducts.NewsSite.ModifyNewsItems"
     menu="zmi_views"
     title="Edit"
+    fields="title teaser body effective expires"
     />
-
+    
 <browser:page
     name="index.html" 
     for=".interfaces.INewsItem"


=== Products3/NewsSite/NewsItem/info.pt 1.8 => 1.9 ===
--- Products3/NewsSite/NewsItem/info.pt:1.8	Thu Mar 27 11:41:09 2003
+++ Products3/NewsSite/NewsItem/info.pt	Thu Mar 27 13:05:03 2003
@@ -6,8 +6,8 @@
 <div metal:fill-slot="body">
 <h2 tal:content="context/title">News Message</h2>
 <p> Creator:&nbsp; <em tal:content="python: ', '.join(view.getCreator())">Creator</em></p>
-<p> <em tal:content="context/lead">News Message</em></p>
-<p tal:content="context/newsbody">News Message</p>
+<p> <em tal:content="context/teaser">News Message</em></p>
+<p tal:content="context/body">News Message</p>
 <p> Effective:&nbsp;
     <span tal:content="view/effectiveString">Effective</span>&nbsp;
     Expires:&nbsp;


=== Products3/NewsSite/NewsItem/interfaces.py 1.6 => 1.7 ===
--- Products3/NewsSite/NewsItem/interfaces.py:1.6	Wed Mar 26 09:24:53 2003
+++ Products3/NewsSite/NewsItem/interfaces.py	Thu Mar 27 13:05:03 2003
@@ -16,17 +16,15 @@
 $Id$
 """
 from zope.interface import Interface
+from zope.app.interfaces.dublincore import IZopeDublinCore
 from zope.schema import Text, TextLine, Datetime
 
 class INewsItem(Interface):
     "Describes the representation of a news item."
 
-    title = TextLine(title=u"News Title")
+    teaser = Text(title=u"News Teaser")
 
-    lead = Text(title=u"News Lead")
+    body = Text(title=u"News Message")
 
-    newsbody = Text(title=u"News Message")
-
-    effective = Datetime(title=u"Effective")
-
-    expires = Datetime(title=u"Expires") 
+class INewsItemForm(INewsItem, IZopeDublinCore):
+    "Describes the extended representation of a news item in a form."


=== Products3/NewsSite/NewsItem/news.py 1.6 => 1.7 ===
--- Products3/NewsSite/NewsItem/news.py:1.6	Wed Mar 26 09:24:53 2003
+++ Products3/NewsSite/NewsItem/news.py	Thu Mar 27 13:05:03 2003
@@ -16,9 +16,9 @@
 $Id$
 """
 import persistence
-from zope.component import getAdapter
-from zope.app.interfaces.dublincore import IZopeDublinCore
+from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
 from interfaces import INewsItem
+from interfaces import INewsItemForm
 
 class NewsItem(persistence.Persistent):
     """News Item.
@@ -26,49 +26,33 @@
 
     __implements__ = INewsItem
 
-    def __init__(self, newsbody=""):
-        # XXX We don't know why setting newsbody=u"" does 
-        #     not save the newsbody value typed in in the 
-        #     form.
-        self.newsbody = newsbody
+    def __init__(self, teaser=u"", body=u""):
+        self.teaser = teaser
+        self.body = body
 
-    def _get_title(self):
-        return getAdapter(self, IZopeDublinCore).title
-        
-    def _set_title(self, value):
-        getAdapter(self, IZopeDublinCore).title = value
-        
-    title = property(_get_title, _set_title, None, 
-                     "getting and setting the title gets and "
-                     "sets the dublin core title")
+class NewsItemAttributesAdapter(ZDCAnnotatableAdapter):
+    """
+    """
 
-    def _get_lead(self):
-        return getAdapter(self, IZopeDublinCore).description
-        
-    def _set_lead(self, value):
-        getAdapter(self, IZopeDublinCore).description = value
+    __implements__ = INewsItemForm
+    __used_for__ = INewsItem
 
-    lead = property(_get_lead, _set_lead, None, 
-                     "getting and setting the lead gets and "
-                     "sets the dublin core description")
+    def __init__(self, context):
+        self.content = context
+        super(NewsItemAttributesAdapter, self).__init__(context)
 
-    def _get_effective(self):
-        return getAdapter(self, IZopeDublinCore).effective
-        
-    def _set_effective(self, value):
-        getAdapter(self, IZopeDublinCore).effective = value
+    def _getbody(self):
+        return self.content.body
 
-    effective = property(_get_effective, _set_effective, None, 
-                     "getting and setting the effective gets and "
-                     "sets the dublin core description")
+    def _setbody(self, value):
+        self.content.body = value
 
-    def _get_expires(self):
-        return getAdapter(self, IZopeDublinCore).expires
-        
-    def _set_expires(self, value):
-        getAdapter(self, IZopeDublinCore).expires = value
+    body = property(_getbody, _setbody, None)
 
-    expires = property(_get_expires, _set_expires, None, 
-                     "getting and setting the expires gets and "
-                     "sets the dublin core description")
+    def _getteaser(self):
+        return self.content.teaser
+        
+    def _setteaser(self, value):
+        self.content.teaser = value
 
+    teaser = property(_getteaser, _setteaser, None)