[Zope3-checkins] CVS: Products3/NewsSite/NewsItem - interfaces.py:1.3 news.py:1.4

Grégoire Weber zope@i-con.ch
Tue, 25 Mar 2003 12:47:13 -0500


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

Modified Files:
	interfaces.py news.py 
Log Message:
Added setter and getter methods for the articles title and lead. They get
saved into dublin cores title and description attributes.


=== Products3/NewsSite/NewsItem/interfaces.py 1.2 => 1.3 ===
--- Products3/NewsSite/NewsItem/interfaces.py:1.2	Tue Mar 25 09:26:52 2003
+++ Products3/NewsSite/NewsItem/interfaces.py	Tue Mar 25 12:47:13 2003
@@ -1,7 +1,11 @@
 from zope.interface import Interface
-from zope.schema import Text
+from zope.schema import Text, TextLine
 
 class INewsItem(Interface):
-    "Provides the ability to change news information."
+    "Describes the representation of a news item."
+
+    title = TextLine(title=u"News Title")
+
+    lead = Text(title=u"News Lead")
 
     newsbody = Text(title=u"News Message")


=== Products3/NewsSite/NewsItem/news.py 1.3 => 1.4 ===
--- Products3/NewsSite/NewsItem/news.py:1.3	Tue Mar 25 09:35:03 2003
+++ Products3/NewsSite/NewsItem/news.py	Tue Mar 25 12:47:13 2003
@@ -1,4 +1,6 @@
 import persistence
+from zope.component import getAdapter
+from zope.app.interfaces.dublincore import IZopeDublinCore
 from interfaces import INewsItem
 
 class NewsItem(persistence.Persistent):
@@ -7,6 +9,31 @@
 
     __implements__ = INewsItem
 
-    def __init__(self, newsbody=''):
-        self.newsbody=newsbody
+    def __init__(self, title=u"", lead=u"", newsbody=""):
+        # XXX We don't know why setting newsbody=u"" does 
+        #     not save the newsbody value typed in in the 
+        #     form.
+        self.title = title
+        self.lead = lead
+        self.newsbody = newsbody
+
+    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")
+
+    def _get_lead(self):
+        return getAdapter(self, IZopeDublinCore).description
+        
+    def _set_lead(self, value):
+        getAdapter(self, IZopeDublinCore).description = value
+
+    lead = property(_get_lead, _set_lead, None, 
+                     "getting and setting the lead gets and "
+                     "sets the dublin core description")