Skip to content

Instantly share code, notes, and snippets.

@jensens
Last active December 21, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensens/6356051 to your computer and use it in GitHub Desktop.
Save jensens/6356051 to your computer and use it in GitHub Desktop.
from plone.app.querystring.queryparser import getPathByUID, getNavigationRoot
def _multi_path(context, row):
values = []
for value in row.values.split():
if not '/' in value:
# It must be a UID
value = '/'.join(getPathByUID(context, value))
# take care of absolute paths without nav_root
nav_root = getNavigationRoot(context)
if not value.startswith(nav_root):
value = nav_root + value
values.append(value)
tmp = {row.index: {'query': values, }}
print tmp
return tmp
<!-- Operation Definitions -->
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="plone">
<records interface="plone.app.querystring.interfaces.IQueryOperation"
prefix="plone.app.querystring.operation.string.multiPath">
<value key="title" i18n:translate="">Multiple absolute paths</value>
<value key="description" i18n:translate="">One or more location in the site structure</value>
<value key="operation">kup.eca.site.querystring._multi_path</value>
<value key="widget">StringWidget</value>
</records>
<!-- QueryField declarations -->
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.path">
<value key="title" i18n:translate="">Location</value>
<value key="description" i18n:translate="">The location of an item </value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.string.relativePath</element>
<element>plone.app.querystring.operation.string.multiPath</element>
<element>plone.app.querystring.operation.string.path</element>
</value>
<value key="group" i18n:translate="">Metadata</value>
</records>
</registry>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment