Commit 67e00d26 authored by Pierre Ducroquet's avatar Pierre Ducroquet

- Add docstrings to the scripts.

- Rename a poorly-named script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31434 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b1b3e336
......@@ -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 @@ return (document.getSourceValue() is not None and document.getSourceValue().getT
<string>_getattr_</string>
<string>context</string>
<string>document</string>
<string>source</string>
<string>None</string>
</tuple>
</value>
......
......@@ -53,11 +53,11 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># Import a standard function, and get the HTML request and response objects.\n
request = container.REQUEST\n
RESPONSE = request.RESPONSE\n
<value> <string>"""\n
This script returns a valid reference to the blog post in context.\n
"""\n
\n
return "%s/%s" % (context.absolute_url(), context.getReference())\n
return "%s/WebPage_viewAsBlog" % context.getReference()\n
</string> </value>
</item>
<item>
......@@ -95,9 +95,6 @@ return "%s/%s" % (context.absolute_url(), context.getReference())\n
<value>
<tuple>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
<string>RESPONSE</string>
<string>context</string>
</tuple>
</value>
......@@ -115,7 +112,7 @@ return "%s/%s" % (context.absolute_url(), context.getReference())\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getPermanentLink</string> </value>
<value> <string>WebSection_getBlogReference</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -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 @@ return result\n
<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>
......
......@@ -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 @@ return printed\n
<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>
......
......@@ -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
......
......@@ -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>
......
19
\ No newline at end of file
23
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment