Commit cfd5fd01 authored by Bartek Górny's avatar Bartek Górny

Jump to "similarity cloud" (any ideas for a better name?) - (#21)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10340 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 457fa183
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>if context.getReference() is None:\n
return context\n
res=context.DMS_findDocument(reference=context.getReference(),language=context.getLanguage())\n
return res[0].getObject()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</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>
<string>None</string>
<string>res</string>
<string>_getitem_</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>DMSDocument_getLastVersion</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -68,14 +68,10 @@ ...@@ -68,14 +68,10 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>def findRecentVersion(doc):\n <value> <string>def getRelatedLatest(category):\n
res=context.DMS_findDocument(reference=doc.getReference(),language=doc.getLanguage())\n
return res[0].getObject()\n
\n
def getRelatedLatest(category):\n
funcname=\'get%sValueList\' % category.title()\n funcname=\'get%sValueList\' % category.title()\n
func=getattr(context,funcname)\n func=getattr(context,funcname)\n
return map(findRecentVersion, func())\n return [o.DMS_getLatestVersion() for o in func()]\n
\n \n
what=kw.get(\'what\')\n what=kw.get(\'what\')\n
if what==\'wiki_predecessor\':\n if what==\'wiki_predecessor\':\n
...@@ -84,6 +80,8 @@ if what==\'wiki_successor\':\n ...@@ -84,6 +80,8 @@ if what==\'wiki_successor\':\n
return context.getWikiSuccessorValueList()\n return context.getWikiSuccessorValueList()\n
if what.startswith(\'related\'):\n if what.startswith(\'related\'):\n
return getRelatedLatest(what[8:])\n return getRelatedLatest(what[8:])\n
if what==\'cloud\':\n
return context.DMS_getSimilarityCloud()\n
if what==\'all\':\n if what==\'all\':\n
dic={}\n dic={}\n
for ob in context.getWikiPredecessorValueList()+context.getWikiSuccessorValueList()+\\\n for ob in context.getWikiPredecessorValueList()+context.getWikiSuccessorValueList()+\\\n
...@@ -135,7 +133,6 @@ return []\n ...@@ -135,7 +133,6 @@ return []\n
<tuple> <tuple>
<string>a</string> <string>a</string>
<string>kw</string> <string>kw</string>
<string>findRecentVersion</string>
<string>getRelatedLatest</string> <string>getRelatedLatest</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>what</string> <string>what</string>
......
...@@ -77,6 +77,7 @@ mapka={\'wiki_predecessor\':\'Wiki Predecessors\',\n ...@@ -77,6 +77,7 @@ mapka={\'wiki_predecessor\':\'Wiki Predecessors\',\n
\'related_similar\':\'Similar documents\',\n \'related_similar\':\'Similar documents\',\n
\'related_successor\':\'Related documents\',\n \'related_successor\':\'Related documents\',\n
\'related_predecessor\':\'Reference documents\',\n \'related_predecessor\':\'Reference documents\',\n
\'cloud\':\'Similarity cloud\',\n
\'all\':\'All related documents\'}\n \'all\':\'All related documents\'}\n
\n \n
s=mapka.get(what)\n s=mapka.get(what)\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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># returns all documents related by similarity (either way), recursively\n
# so all documents related indirectly are also returned\n
# recursion depth can be limited, to avoid returning all documents\n
# if there is many similarities\n
# every doc is returned in its latest version available\n
\n
lista={}\n
depth=int(depth)\n
\n
def getSimilarities(self,level=0):\n
level+=1\n
context.log(self.getRelativeUrl())\n
context.log(level)\n
res=self.getSimilarValueList()+self.getSimilarRelatedValueList()\n
for r in res:\n
if lista.get(r) is None:\n
lista[r]=True\n
if level!=depth:\n
getSimilarities(r,level)\n
\n
getSimilarities(context)\n
if lista.has_key(context):lista.pop(context)\n
return [o.DMSDocument_getLastVersion() for o in lista.keys()]\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>depth=0</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>depth</string>
<string>lista</string>
<string>int</string>
<string>getSimilarities</string>
<string>context</string>
<string>_getattr_</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>o</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DMS_getSimilarityCloud</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
196 199
\ No newline at end of file \ 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