[CMF-checkins] SVN: CMF/trunk/CMFDefault/browser/ viewification, part 3 (merging from tseaver-viewification branch):

Yvo Schubbe y.2006_ at wcm-solutions.de
Wed Feb 22 13:06:04 EST 2006


Log message for revision 41750:
  viewification, part 3 (merging from tseaver-viewification branch):
  - added link views (link_view, link_edit_form)
  - added favorite views (favorite_view)

Changed:
  U   CMF/trunk/CMFDefault/browser/TODO.txt
  U   CMF/trunk/CMFDefault/browser/configure.zcml
  A   CMF/trunk/CMFDefault/browser/link.py
  _U  CMF/trunk/CMFDefault/browser/templates/document_edit.pt
  A   CMF/trunk/CMFDefault/browser/templates/link.pt
  A   CMF/trunk/CMFDefault/browser/templates/link_edit.pt
  _U  CMF/trunk/CMFDefault/browser/templates/metadata_edit.pt
  _U  CMF/trunk/CMFDefault/browser/templates/newsitem_edit.pt

-=-
Modified: CMF/trunk/CMFDefault/browser/TODO.txt
===================================================================
--- CMF/trunk/CMFDefault/browser/TODO.txt	2006-02-22 17:51:42 UTC (rev 41749)
+++ CMF/trunk/CMFDefault/browser/TODO.txt	2006-02-22 18:06:03 UTC (rev 41750)
@@ -76,18 +76,18 @@
       validateTextFile.py -> DocumentEditView.validateTextFile
       newsitem_edit_control.py -> NewsItemEditView.edit_control
 
-  [ ] link_view:
+  [x] link_view:
 
       link_view.py -> LinkView
       link_view_template.pt -> templates/link.pt
 
-  [ ] link_edit_form:
+  [x] link_edit_form:
 
       link_edit_form.py -> LinkEditView
       link_edit_template.pt -> templates/link_edit.pt
       link_edit_control.py -> LinkEditView.edit_control
 
-  [ ] favorite_view:
+  [x] favorite_view:
 
       favorite_view.py -> LinkView
       link_view_template.pt -> templates/link.pt
@@ -113,3 +113,5 @@
       image_edit_form.py -> ImageEditView
       image_edit_template.pt -> templates/image_edit.pt
       image_edit_control.py -> ImageEditView.edit_control
+
+  [ ] complete this todo list

Modified: CMF/trunk/CMFDefault/browser/configure.zcml
===================================================================
--- CMF/trunk/CMFDefault/browser/configure.zcml	2006-02-22 17:51:42 UTC (rev 41749)
+++ CMF/trunk/CMFDefault/browser/configure.zcml	2006-02-22 18:06:03 UTC (rev 41750)
@@ -87,6 +87,33 @@
       />
 
   <browser:page
+      for="Products.CMFDefault.interfaces.ILink"
+      name="link_view"
+      class=".link.LinkView"
+      template="templates/link.pt"
+      permission="zope2.View"
+      layer="cmf"
+      />
+
+  <browser:page
+      for="Products.CMFDefault.interfaces.IMutableLink"
+      name="link_edit_form"
+      class=".link.LinkEditView"
+      template="templates/link_edit.pt"
+      permission="cmf.ModifyPortalContent"
+      layer="cmf"
+      />
+
+  <browser:page
+      for="Products.CMFDefault.interfaces.IFavorite"
+      name="favorite_view"
+      class=".link.LinkView"
+      template="templates/link.pt"
+      permission="zope2.View"
+      layer="cmf"
+      />
+
+  <browser:page
       for="*"
       name="form_widget"
       template="templates/form_widgets.pt"

Added: CMF/trunk/CMFDefault/browser/link.py
===================================================================
--- CMF/trunk/CMFDefault/browser/link.py	2006-02-22 17:51:42 UTC (rev 41749)
+++ CMF/trunk/CMFDefault/browser/link.py	2006-02-22 18:06:03 UTC (rev 41750)
@@ -0,0 +1,74 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Browser views for links.
+
+$Id$
+"""
+
+import urlparse
+
+from Products.CMFDefault.exceptions import ResourceLockedError
+from Products.CMFDefault.utils import Message as _
+
+from utils import decode
+from utils import FormViewBase
+from utils import memoize
+from utils import ViewBase
+
+
+class LinkView(ViewBase):
+
+    """View for ILink.
+    """
+
+    # interface
+
+    @memoize
+    @decode
+    def url(self):
+        return self.context.getRemoteUrl()
+
+
+class LinkEditView(FormViewBase):
+
+    """Edit view for IMutableLink.
+    """
+
+    _BUTTONS = ({'id': 'change',
+                 'title': _(u'Change'),
+                 'transform': ('edit_control',),
+                 'redirect': ('portal_types', 'object/edit')},
+                {'id': 'change_and_view',
+                 'title': _(u'Change and View'),
+                 'transform': ('edit_control',),
+                 'redirect': ('portal_types', 'object/view')})
+
+    # interface
+
+    @memoize
+    @decode
+    def remote_url(self):
+        return self.request.form.get('remote_url', self.context.remote_url)
+
+    # controllers
+
+    def edit_control(self, remote_url, **kw):
+        context = self.context
+        if remote_url != context.remote_url:
+            try:
+                context.edit(remote_url=remote_url)
+                return True, _(u'Link changed.')
+            except ResourceLockedError, errmsg:
+                return False, errmsg
+        else:
+            return False, _(u'Nothing to change.')


Property changes on: CMF/trunk/CMFDefault/browser/link.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native


Property changes on: CMF/trunk/CMFDefault/browser/templates/document_edit.pt
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision

Copied: CMF/trunk/CMFDefault/browser/templates/link.pt (from rev 41748, CMF/trunk/CMFDefault/skins/zpt_content/link_view_template.pt)
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_content/link_view_template.pt	2006-02-22 10:02:41 UTC (rev 41748)
+++ CMF/trunk/CMFDefault/browser/templates/link.pt	2006-02-22 18:06:03 UTC (rev 41750)
@@ -0,0 +1,31 @@
+<html metal:use-macro="context/@@standard_macros/page">
+<head>
+
+<metal:slot fill-slot="base">
+<tal:span tal:replace="structure context/getBaseTag" />
+</metal:slot>
+
+</head>
+<body>
+
+<metal:slot metal:fill-slot="header">
+<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" />
+</metal:slot>
+
+<metal:slot metal:fill-slot="body" i18n:domain="cmf_default">
+<p i18n:translate="">Link:
+ <a href="" tal:attributes="href view/url" tal:content="view/url"
+    i18n:name="link">http://www.zope.org</a></p>
+
+<div class="Discussion" tal:condition="context/viewThreadsAtBottom|nothing">
+ <tal:span tal:replace="structure context/viewThreadsAtBottom" />
+</div>
+</metal:slot>
+
+</body>
+</html>

Copied: CMF/trunk/CMFDefault/browser/templates/link_edit.pt (from rev 41748, CMF/trunk/CMFDefault/skins/zpt_content/link_edit_template.pt)
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_content/link_edit_template.pt	2006-02-22 10:02:41 UTC (rev 41748)
+++ CMF/trunk/CMFDefault/browser/templates/link_edit.pt	2006-02-22 18:06:03 UTC (rev 41750)
@@ -0,0 +1,39 @@
+<html metal:use-macro="context/@@standard_macros/page">
+<body>
+
+<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
+<h1 i18n:translate="">Edit: <tal:span
+    tal:content="view/title" i18n:name="obj_title">Title</tal:span></h1>
+</metal:slot>
+
+<metal:slot metal:fill-slot="body" i18n:domain="cmf_default">
+<div class="Desktop">
+
+<form action="link_edit_form" method="post"
+   tal:attributes="action view/form_action">
+<table class="FormLayout">
+ <tr>
+  <th i18n:translate="">Title</th>
+  <td tal:content="view/title">Title</td>
+ </tr>
+ <tr>
+  <th i18n:translate="">URL</th>
+  <td>
+   <input type="text" name="remote_url" value=""
+          tal:attributes="value view/remote_url" />
+  </td>
+ </tr>
+ <tr>
+  <td>&nbsp;</td>
+  <td>
+   <metal:macro metal:use-macro="context/@@form_widget/buttons" />
+  </td>
+ </tr>
+</table>
+</form>
+
+</div>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFDefault/browser/templates/link_edit.pt
___________________________________________________________________
Name: svn:eol-style
   + native


Property changes on: CMF/trunk/CMFDefault/browser/templates/metadata_edit.pt
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision


Property changes on: CMF/trunk/CMFDefault/browser/templates/newsitem_edit.pt
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision



More information about the CMF-checkins mailing list