[Zope3-checkins] CVS: Zope3/src/zope/app/pagetemplate - talesapi.py:1.2

Jim Fulton jim@zope.com
Fri, 23 May 2003 18:19:09 -0400


Update of /cvs-repository/Zope3/src/zope/app/pagetemplate
In directory cvs.zope.org:/tmp/cvs-serv20263/src/zope/app/pagetemplate

Modified Files:
	talesapi.py 
Log Message:
Added several attributes and methods to the Zope tales api.


=== Zope3/src/zope/app/pagetemplate/talesapi.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/pagetemplate/talesapi.py:1.1	Tue Apr 15 14:52:57 2003
+++ Zope3/src/zope/app/pagetemplate/talesapi.py	Fri May 23 18:18:38 2003
@@ -18,8 +18,9 @@
 """
 
 from zope.app.interfaces.talesapi import IZopeTalesAPI
-from zope.app.interfaces.dublincore import IZopeDublinCore
-from zope.component import queryAdapter
+from zope.app.interfaces.dublincore import IDCDescriptiveProperties, IDCTimes
+from zope.app.interfaces.size import ISized
+from zope.app import zapi
 
 class ZopeTalesAPI(object):
 
@@ -29,7 +30,44 @@
         self.context = context
 
     def title(self):
-        a = queryAdapter(self.context, IZopeDublinCore)
+        a = zapi.queryAdapter(self.context, IDCDescriptiveProperties)
         if a is None:
             raise AttributeError, 'title'
         return a.title
+    title = property(title)
+
+    def description(self):
+        a = zapi.queryAdapter(self.context, IDCDescriptiveProperties)
+        if a is None:
+            raise AttributeError, 'description'
+        return a.description
+    description = property(description)
+
+    def created(self):
+        a = zapi.queryAdapter(self.context, IDCTimes)
+        if a is None:
+            raise AttributeError, 'created'
+        return a.created
+    created = property(created)
+
+    def modified(self):
+        a = zapi.queryAdapter(self.context, IDCTimes)
+        if a is None:
+            raise AttributeError, 'modified'
+        return a.modified
+    modified = property(modified)
+
+    def name(self):
+        return zapi.name(self.context)
+
+    def title_or_name(self):
+        return getattr(self, 'title', '') or zapi.name(self.context)
+
+    def size(self):
+        a = zapi.queryAdapter(self.context, ISized)
+        if a is None:
+            raise AttributeError, 'created'
+        return a.sizeForDisplay()
+
+    
+