[Erp5-report] r31433 pierre.ducroquet - in /erp5/trunk/bt5/erp5_web_blog: SkinTemplateItem/...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Dec 23 11:29:39 CET 2009


Author: pierre.ducroquet
Date: Wed Dec 23 11:29:36 2009
New Revision: 31433

URL: http://svn.erp5.org?rev=31433&view=rev
Log:
- Add docstrings to the scripts.
- Rename a poorly-named script.

Added:
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getBlogReference.xml
Modified:
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getAuthorName.xml
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getCategoryList.xml
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getPostList.xml
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_viewBlogFrontPage/listbox.xml
    erp5/trunk/bt5/erp5_web_blog/bt/revision

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getAuthorName.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getAuthorName.xml?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getAuthorName.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getAuthorName.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -53,25 +53,13 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>#request = container.REQUEST\n
-#RESPONSE =  request.RESPONSE\n
-\n
-#context.pdb_trace(context.getObject())\n
+            <value> <string>"""\n
+  This simple script returns the author name of the current context.\n
+"""\n
 \n
 document = context.getObject()\n
-#user_name = document.getOwnerInfo()[\'id\']\n
-return (document.getSourceValue() is not None and document.getSourceValue().getTitle() or "User unknown")\n
-\n
-#portal = context.getPortalObject()\n
-#found_user_list = portal.portal_catalog(portal_type=\'Person\', reference=user_name)\n
-#found_user_count = len(found_user_list)\n
-#if found_user_count != 1:\n
-#  person_name = user_name\n
-#else:\n
-#  person = found_user_list[0].getObject()\n
-#  person_name = person.getName()\n
-\n
-#return person_name\n
+source = document.getSourceValue()\n
+return (source is not None and source.getTitle() or "User unknown")\n
 </string> </value>
         </item>
         <item>
@@ -119,6 +107,7 @@
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>document</string>
+                            <string>source</string>
                             <string>None</string>
                           </tuple>
                         </value>

Added: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getBlogReference.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getBlogReference.xml?rev=31433&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getBlogReference.xml (added)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getBlogReference.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -1,0 +1,126 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>"""\n
+  This script returns a valid reference to the blog post in context.\n
+"""\n
+\n
+return "%s/WebPage_viewAsBlog" % context.getReference()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>WebSection_getBlogReference</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getCategoryList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getCategoryList.xml?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getCategoryList.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getCategoryList.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -53,20 +53,31 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>current_section = context.getWebSectionValue()\n
+            <value> <string>"""\n
+  This script returns the list of category (or tags) that are available in the current web section.\n
+  It returns a python list of Category object. A Category object is really simple, as it has just \n
+  one property with a getter and a setter : title.\n
+"""\n
+\n
+\n
+## First step : retrieve the raw list\n
+current_section = context.getWebSectionValue()\n
 subject_list = []\n
+\n
 for item in current_section.WebSection_getDocumentValueList():\n
-  subject_list.extend(item.getSubjectList())\n
+  subject_list.extend([x for x in item.getSubjectList() if not x in subject_list])\n
 \n
+## Now, build the object list so that a Listbox can be used to display the results of this script.\n
 result = []\n
-class FakeObject:\n
+\n
+class Category:\n
   def setTitle(self, title):\n
     self.title = title\n
   def getTitle(self):\n
     return self.title\n
 \n
 for item in subject_list:\n
-  obj = FakeObject()\n
+  obj = Category()\n
   obj.setTitle(item)\n
   result.append(obj)\n
 \n
@@ -114,8 +125,11 @@
                             <string>subject_list</string>
                             <string>_getiter_</string>
                             <string>item</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>x</string>
                             <string>result</string>
-                            <string>FakeObject</string>
+                            <string>Category</string>
                             <string>obj</string>
                           </tuple>
                         </value>

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -55,13 +55,15 @@
             <key> <string>_body</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
-request = container.REQUEST\n
-RESPONSE =  request.RESPONSE\n
-\n
+"""\n
+  This simple script returns the first paragraph of an HTML or raw text.\n
+  In the case of a raw text, the first line is returned, splitted by \\n.\n
+"""\n
 content = context.getTextContent()\n
-print content.split("</p>")[0] + "</p>"\n
-\n
-return printed\n
+if "</p>" in content:\n
+  return content.split("</p>")[0] + "</p>"\n
+else:\n
+  return content.split("\\n")[0]\n
 
 
 ]]></string> </value>
@@ -100,12 +102,7 @@
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>_print_</string>
-                            <string>_print</string>
                             <string>_getattr_</string>
-                            <string>container</string>
-                            <string>request</string>
-                            <string>RESPONSE</string>
                             <string>context</string>
                             <string>content</string>
                             <string>_getitem_</string>

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getPostList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getPostList.xml?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getPostList.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getPostList.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -53,7 +53,13 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>request = container.REQUEST\n
+            <value> <string>"""\n
+  This script returns the blog post that must be displayed in the current section.\n
+  The blog post are filtered through the tag parameter that is retrieved through\n
+  the GET parameters.\n
+"""\n
+\n
+request = container.REQUEST\n
 \n
 requested_tag = request.get(\'tag\')\n
 current_section = context.getWebSectionValue()\n

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_viewBlogFrontPage/listbox.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_viewBlogFrontPage/listbox.xml?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_viewBlogFrontPage/listbox.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_viewBlogFrontPage/listbox.xml [utf8] Wed Dec 23 11:29:36 2009
@@ -373,7 +373,7 @@
                           <string>Categories</string>
                         </tuple>
                         <tuple>
-                          <string>reference</string>
+                          <string>WebSection_getBlogReference</string>
                           <string>Reference</string>
                         </tuple>
                         <tuple>
@@ -381,7 +381,7 @@
                           <string>Summary</string>
                         </tuple>
                         <tuple>
-                          <string>Discussion_getCommentCount</string>
+                          <string>DiscussionThread_getContextPostCount</string>
                           <string>Comment Count</string>
                         </tuple>
                       </list>

Modified: erp5/trunk/bt5/erp5_web_blog/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/bt/revision?rev=31433&r1=31432&r2=31433&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/bt/revision [utf8] Wed Dec 23 11:29:36 2009
@@ -1,1 +1,1 @@
-19
+23




More information about the Erp5-report mailing list