[CMF-checkins] SVN: CMF/trunk/CMFTopic/skins/zpt_topic/topic_ - made sure encoded strings are converted to unicode

Yvo Schubbe y.2006_ at wcm-solutions.de
Sun Feb 5 16:30:53 EST 2006


Log message for revision 41567:
  - made sure encoded strings are converted to unicode
  - some related refactoring and cleanup

Changed:
  D   CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py
  A   CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_control.py
  D   CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt
  A   CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.py
  A   CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_template.pt
  D   CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt
  A   CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.py
  A   CMF/trunk/CMFTopic/skins/zpt_topic/topic_view_template.pt

-=-
Deleted: CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py	2006-02-05 21:27:18 UTC (rev 41566)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py	2006-02-05 21:30:52 UTC (rev 41567)
@@ -1,15 +0,0 @@
-## Script (Python) "topic_editTopic"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=REQUEST, RESPONSE, acquireCriteria, title=None, description=None
-##title=
-##
-
-context.edit(acquireCriteria=acquireCriteria,
-             title=title,
-             description=description)
-
-RESPONSE.redirect('%s/topic_view' % context.absolute_url())

Copied: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_control.py (from rev 41533, CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py)
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_editTopic.py	2006-02-01 15:10:13 UTC (rev 41533)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_control.py	2006-02-05 21:30:52 UTC (rev 41567)
@@ -0,0 +1,11 @@
+##parameters=title, description, acquireCriteria=False, **kw
+##
+from Products.CMFDefault.utils import Message as _
+
+if title!=context.title or description != context.description or \
+        acquireCriteria != context.acquireCriteria:
+    context.edit(title=title, description=description,
+                 acquireCriteria=acquireCriteria)
+    return context.setStatus(True, _(u'Topic changed.'))
+else:
+    return context.setStatus(False, _(u'Nothing to change.'))


Property changes on: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_control.py
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt	2006-02-05 21:27:18 UTC (rev 41566)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt	2006-02-05 21:30:52 UTC (rev 41567)
@@ -1,53 +0,0 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-    xmlns:metal="http://xml.zope.org/namespaces/metal"
-    metal:use-macro="container/main_template/macros/master">
-<body>
-<div metal:fill-slot="main">
-
-<div class="Desktop">
-
-<div class="Topic">
-
-<h2> Edit Topic: <span tal:replace="here/id" /> </h2>
-
-<form action="" method="post" tal:attributes="action here/absolute_url">
-<table class="FormLayout">
-
- <tr valign="top">
-  <th align="right"> Title: </th>
-  <td><input type="text" name="title" value="Title" size="30" tal:attributes="value here/title" /></td>
- </tr>
- <tr valign="top">
-  <th align="right"> Description: </th>
-  <td><textarea name="description:text" rows="5" cols="65"
-        tal:content="here/description"
-       >Description</textarea></td>
- </tr>
- <tr valign="top">
-  <th align="right"> Acquire Criteria<br>from Parent: </th>
-  <td>
-   <input type="checkbox"
-          name="acquireCriteria"
-          value="1" tal:attributes="checked python:here.acquireCriteria and 'checked' or ''">
-   <input type="hidden"
-          name="acquireCriteria:default"
-          value="">
-  </td>
- </tr>
-
- <tr valign="top">
-  <td> <br> </td>
-  <td>
-   <input type="submit" name="topic_editTopic:action" value="Change">
-  </td>
- </tr>
-
-</table>
-</form>
-
-</div>
-
-</div>
-</div>
-</body>
-</html>

Added: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.py
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.py	2006-02-05 21:27:18 UTC (rev 41566)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.py	2006-02-05 21:30:52 UTC (rev 41567)
@@ -0,0 +1,31 @@
+##parameters=change='', change_and_view=''
+##
+from Products.CMFDefault.utils import decode
+from Products.CMFDefault.utils import Message as _
+
+form = context.REQUEST.form
+if change and \
+        context.topic_edit_control(**form) and \
+        context.setRedirect(context, 'object/edit'):
+    return
+elif change_and_view and \
+        context.topic_edit_control(**form) and \
+        context.setRedirect(context, 'object/view'):
+    return
+
+
+options = {}
+
+options['title'] = form.get('title', context.Title())
+options['description'] = form.get('description', context.Description())
+options['acquireCriteria'] = form.get('acquireCriteria',
+                                      context.acquireCriteria)
+
+buttons = []
+target = context.getActionInfo('object/edit')['url']
+buttons.append( {'name': 'change', 'value': _(u'Change')} )
+buttons.append( {'name': 'change_and_view', 'value': _(u'Change and View')} )
+options['form'] = { 'action': target,
+                    'listButtonInfos': tuple(buttons) }
+
+return context.topic_edit_template(**decode(options, script))


Property changes on: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.py
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_template.pt (from rev 41533, CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt)
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_form.pt	2006-02-01 15:10:13 UTC (rev 41533)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_template.pt	2006-02-05 21:30:52 UTC (rev 41567)
@@ -0,0 +1,50 @@
+<html metal:use-macro="context/main_template/macros/master">
+<body>
+
+<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
+<h1 i18n:translate="">Edit: <tal:span
+    tal:content="options/title" i18n:name="obj_title">Title</tal:span></h1>
+</metal:slot>
+
+<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
+   tal:define="form options/form">
+<div class="Desktop">
+
+<form action="topic_edit_form" method="post"
+   tal:attributes="action form/action">
+<table class="FormLayout">
+ <tr>
+  <th i18n:translate="">Title</th>
+  <td>
+   <input type="text" name="title" value="" size="65"
+      tal:attributes="value options/title" />
+  </td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Description</th>
+  <td>
+   <textarea name="description:text" rows="5" cols="65" wrap="soft"
+      tal:content="options/description"></textarea>
+  </td>
+ </tr>
+ <tr>
+  <th i18n:translate="">Acquire Criteria from Parent</th>
+  <td>
+   <input type="checkbox" name="acquireCriteria:boolean"
+      tal:attributes="checked options/acquireCriteria" />
+  </td>
+ </tr>
+ <tr>
+  <td>&nbsp;</td>
+  <td>
+   <metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
+  </td>
+ </tr>
+</table>
+</form>
+
+</div>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFTopic/skins/zpt_topic/topic_edit_template.pt
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt	2006-02-05 21:27:18 UTC (rev 41566)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt	2006-02-05 21:30:52 UTC (rev 41567)
@@ -1,76 +0,0 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
-<head>
- <metal:block fill-slot="base"
- ><tal:span tal:replace="structure here/getBaseTag"
-/></metal:block>
-</head>
-<body>
-
-<div metal:fill-slot="main">
-
-<div class="Desktop">
-
-<div class="Topic">
-
-<h2><span tal:replace="here/title">title</span> </h2>
-
-<span tal:define="topics python:here.objectValues( [ 'Portal Topic' ] )"
-      tal:condition="topics">
-    <h4>Subtopics: </h4>
-    <div tal:repeat="topic topics">
-        <a href=""
-            tal:define="topictitle python:topic.Title() or topic.getId()"
-            tal:attributes="href topic/absolute_url"
-            tal:content="topictitle">
-                Topic Title
-            </a>
-    </div>
-</span>
-
-<span tal:define="
-            b_start string:0;b_start request/b_start | b_start;
-            results here/queryCatalog;
-            Batch python:modules['ZTUtils'].Batch;
-            global batch python:Batch(results, 20, int(b_start), orphan=1)">
-    <h4>Topic Matches: </h4>
-    <div tal:repeat="match batch" tal:condition="batch">
-        <a href=""
-            tal:attributes="href string:${match/getURL}/view"
-        ><tal:span tal:content="match/getId">ID</tal:span>
-        <tal:case tal:condition="match/Title"
-           tal:content="string:(${match/Title})">(Title)</tal:case
-      ></a>
-    </div>
-
-
-    <span tal:define="p batch/previous" tal:condition="p">
-    <a href=""
-        tal:attributes="href string:?b_start=${p/first}">Previous <span
-        tal:replace="p/length">n</span> items</a>
-    </span>&nbsp;&nbsp;
-    <span tal:define="n batch/next" tal:condition="n">
-    <a href=""
-        tal:attributes="href string:?b_start=${batch/end}">Next <span
-        tal:replace="n/length">n</span> items</a>
-    </span>
-
-    <h3> Query Parameters </h3>
-
-    <ul tal:define="queries here/buildQuery; items python:queries.items()"
-        tal:condition="queries">
-    <span tal:repeat="item items">
-    <li tal:define="key python:item[0]; value python:item[1]"
-        tal:content="string:${key} : ${value}">item</li>
-    </span>
-    </ul>
-</span>
-
-</div>
-
-</div>
-</div>
-
-</body>
-</html>

Added: CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.py
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.py	2006-02-05 21:27:18 UTC (rev 41566)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.py	2006-02-05 21:30:52 UTC (rev 41567)
@@ -0,0 +1,33 @@
+##parameters=b_start=0
+##
+from ZTUtils import Batch
+from Products.CMFDefault.utils import decode
+
+
+options = {}
+
+subtopics = [ {'title': item.Title() or item.getId(),
+               'url': item.absolute_url()}
+              for item in context.contentValues() ]
+options['listSubtopicInfos'] = subtopics
+
+queries = context.buildQuery()
+options['listQueries'] = tuple([ '%s: %s' % q for q in queries.items() ])
+
+target = context.REQUEST['ACTUAL_URL']
+items = context.queryCatalog()
+batch_obj = Batch(items, 20, b_start, orphan=1)
+
+items = [ {'creators': item.listCreators,
+           'date': item.Date,
+           'description': item.Description,
+           'id': item.getId,
+           'title': item.Title and ('(%s)' % item.Title) or '',
+           'url': '%s/view' % item.getURL()}
+          for item in batch_obj ]
+
+navigation = context.getBatchNavigation(batch_obj, target)
+options['batch'] = {'listItemInfos': items,
+                    'navigation': navigation}
+
+return context.topic_view_template(**decode(options, script))


Property changes on: CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.py
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: CMF/trunk/CMFTopic/skins/zpt_topic/topic_view_template.pt (from rev 41533, CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt)
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_view.pt	2006-02-01 15:10:13 UTC (rev 41533)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_view_template.pt	2006-02-05 21:30:52 UTC (rev 41567)
@@ -0,0 +1,43 @@
+<html metal:use-macro="context/main_template/macros/master">
+<head>
+
+<metal:slot fill-slot="base">
+<tal:span tal:replace="structure context/getBaseTag" />
+</metal:slot>
+
+</head>
+<body>
+
+<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
+   tal:define="batch options/batch">
+<div class="Desktop">
+
+<tal:case tal:condition="options/listSubtopicInfos"
+><h4 i18n:translate="">Subtopics:</h4>
+ <div tal:repeat="item_info options/listSubtopicInfos">
+   <a href="" tal:attributes="href item_info/url"
+      tal:content="item_info/title">Topic Title</a>
+ </div
+></tal:case>
+
+<h4 i18n:translate="">Topic Matches:</h4>
+<div tal:repeat="item_info batch/listItemInfos">
+ <a href="" tal:attributes="href item_info/url"
+ ><tal:span tal:content="item_info/id">ID</tal:span>
+  <tal:case tal:condition="item_info/title"
+     tal:content="item_info/title">(Title)</tal:case></a>
+</div>
+
+<metal:macro metal:use-macro="context/batch_widgets/macros/navigation" />
+
+<h4 i18n:translate="">Query Parameters:</h4>
+
+<ul tal:condition="options/listQueries">
+ <li tal:repeat="item options/listQueries" tal:content="item">item</li>
+</ul>
+
+</div>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFTopic/skins/zpt_topic/topic_view_template.pt
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the CMF-checkins mailing list