[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/ - added file view

Yvo Schubbe cvs-admin at zope.org
Wed Jul 18 09:31:58 UTC 2012


Log message for revision 127348:
  - added file view

Changed:
  U   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml
  A   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.pt
  U   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.py

-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml	2012-07-18 07:06:13 UTC (rev 127347)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml	2012-07-18 09:31:50 UTC (rev 127348)
@@ -143,9 +143,13 @@
       factory=".file.FileAddView"
       />
 
-  <adapter
-      name="cmf.image"
-      factory=".file.FileAddView"
+  <browser:page
+      for="Products.CMFDefault.interfaces.IFile"
+      layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+      name="view.html"
+      class=".file.FileView"
+      template="file.pt"
+      permission="zope2.View"
       />
 
   <browser:page
@@ -156,6 +160,11 @@
       permission="cmf.ModifyPortalContent"
       />
 
+  <adapter
+      name="cmf.image"
+      factory=".file.FileAddView"
+      />
+
   <browser:page
       for="Products.CMFDefault.interfaces.IImage"
       layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"

Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.pt	                        (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.pt	2012-07-18 09:31:50 UTC (rev 127348)
@@ -0,0 +1,48 @@
+<html metal:use-macro="context/@@standard_macros/page">
+<head>
+
+<metal:slot fill-slot="style_slot">
+<tal:span tal:replace="structure context/getBaseTag" />
+</metal:slot>
+
+</head>
+<body>
+
+<metal:slot metal:fill-slot="body" i18n:domain="cmf_default">
+<h1 id="DesktopTitle" tal:content="view/title">Document Title</h1>
+
+<div id="DesktopDescription" tal:content="view/description">Document
+ Description goes here.</div>
+
+<metal:macro metal:use-macro="context/content_byline/macros/byline" />
+
+<h2 i18n:translate="">File Properties</h2>
+
+<table>
+ <tr>
+  <th i18n:translate="">Filename</th>
+  <td tal:content="view/id">My ID</td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Size</th>
+  <td tal:content="view/size">1024K</td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Content-type</th>
+  <td tal:content="view/content_type">application/gzip</td>
+ </tr>
+</table>
+
+<h2 i18n:translate="">Download File</h2>
+
+<p><a href="." title="Download File"
+    tal:attributes="href view/url; title view/title"
+    tal:content="string:Download ${view/title}">Download File</a></p>
+
+<div class="Discussion" tal:condition="context/viewThreadsAtBottom|nothing">
+ <tal:span tal:replace="structure context/viewThreadsAtBottom" />
+</div>
+</metal:slot>
+
+</body>
+</html>


Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.pt
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.py	2012-07-18 07:06:13 UTC (rev 127347)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/file.py	2012-07-18 09:31:50 UTC (rev 127348)
@@ -21,6 +21,9 @@
 from zope.schema import Text
 from zope.schema import TextLine
 
+from Products.CMFDefault.browser.utils import decode
+from Products.CMFDefault.browser.utils import memoize
+from Products.CMFDefault.browser.utils import ViewBase
 from Products.CMFDefault.formlib.form import ContentAddFormBase
 from Products.CMFDefault.formlib.form import ContentEditFormBase
 from Products.CMFDefault.formlib.schema import FileUpload
@@ -83,6 +86,34 @@
     file = property(_getFile, _setFile)
 
 
+class FileView(ViewBase):
+
+    """View for IFile.
+    """
+
+    # interface
+
+    @memoize
+    @decode
+    def content_type(self):
+        return self.context.getContentType()
+
+    @memoize
+    @decode
+    def id(self):
+        return self.context.getId()
+
+    @memoize
+    @decode
+    def size(self):
+        return self.context.get_size()
+
+    @memoize
+    @decode
+    def url(self):
+        return self.context.absolute_url()
+
+
 class FileAddView(ContentAddFormBase):
 
     """Add view for IMutableFile.



More information about the checkins mailing list