<?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>from ZTUtils import make_query\n
Base_translateString = context.Base_translateString\n
checkPerm = context.portal_membership.checkPermission\n
\n
if jump_from_relative_url is None:\n
  relation = context\n
else:\n
  relation = context.getPortalObject().restrictedTraverse(jump_from_relative_url)\n
\n
# FIXME: performance problem getting *all* related documents URL is not scalable.\n
getter_base_name = \'\'.join([x.capitalize() for x in base_category.split(\'_\')])\n
if related:\n
  search_method = getattr(relation, \'get%sRelatedList\' % getter_base_name)\n
else:\n
  search_method = getattr(relation, \'get%sList\' % getter_base_name)\n
\n
related_list = search_method(portal_type = portal_type)\n
\n
if same_type(portal_type, \'\'):\n
  portal_type = [portal_type]\n
\n
relation_found = 0\n
if len(related_list) == 0:\n
  url = context.absolute_url()\n
  message = Base_translateString(\n
    \'No %s Related\' % portal_type[0],\n
    default = unicode(Base_translateString(\'No ${portal_type} related.\',\n
                                           mapping = { \'portal_type\': Base_translateString(portal_type[0])}), \'utf8\'))\n
\n
elif len(related_list) == 1:\n
  relation_found = 1\n
  related_object = context.restrictedTraverse(related_list[0], None)\n
  if related_object is None:\n
    # this might be a category\n
    related_object = context.portal_categories.resolveCategory(\n
                           "%s/%s" % (base_category, related_list[0]))\n
\n
  if related_object is not None and checkPerm("View", related_object) :\n
    if target_form_id is not None:\n
      form_id = target_form_id\n
    else:\n
      form_id = \'view\'\n
    url = related_object.absolute_url()\n
    message = Base_translateString(\n
      # first, try to get a full translated message with portal types\n
      "%s related to %s." % (related_object.getPortalType(), context.getPortalType()),\n
       # if not found, fallback to generic translation\n
      default = unicode(Base_translateString(\'${this_portal_type} related to ${that_portal_type} : ${that_title}.\',\n
        mapping={"this_portal_type" : related_object.getTranslatedPortalType(),\n
                 "that_portal_type" : context.getTranslatedPortalType(),\n
                 "that_title" : context.getTitleOrId() }), \'utf8\'))\n
  else :\n
    url = context.absolute_url()\n
    message = Base_translateString("You are not authorized to view the related document.")\n
    relation_found = 0\n
\n
else:\n
  # jump to the module if we can guess it\n
  if len(portal_type) == 1:\n
    module_id = context.getPortalObject().getDefaultModuleId(portal_type[0], None)\n
    if module_id is not None:\n
      if related:\n
        return context.getPortalObject().getDefaultModule(portal_type[0]).Base_redirect(\n
                 \'view\', keep_items={\'default_%s_uid\' % base_category: relation.getUid(),\n
                                     \'reset\': 1})\n
      get_uid_method = getattr(relation, \'get%sUidList\' % getter_base_name)\n
      return context.getPortalObject().getDefaultModule(portal_type[0]).Base_redirect(\n
                 \'view\', keep_items=dict(\n
                           reset=1,\n
                           uid=get_uid_method(portal_type=portal_type,\n
                                              checked_permission=\'View\')))\n
\n
  # compute the list of objects we are actually authorized to view\n
  related_object_list = []\n
  for path in search_method(portal_type=portal_type) :\n
    obj = context.getPortalObject().restrictedTraverse(path, None)\n
    if obj is None:\n
      # this might be a category\n
      obj = context.portal_categories.resolveCategory(\n
                           "%s/%s" % (base_category, path))\n
\n
    if obj is not None and checkPerm("View", obj):\n
      related_object_list.append(obj)\n
  if len(related_object_list) == 0 :\n
    url = context.absolute_url()\n
    message = Base_translateString("You are not authorized to view any related document.")\n
    relation_found = 0\n
  else :\n
    request=context.REQUEST\n
    selection_uid_list = [x.getUid() for x in related_object_list]\n
    kw = {\'uid\': selection_uid_list}\n
    context.portal_selections.setSelectionParamsFor(\n
                          \'Base_jumpToRelatedObjectList\', kw)\n
    request.set(\'object_uid\', context.getUid())\n
    request.set(\'uids\', selection_uid_list)\n
    return context.Base_jumpToRelatedObjectList(\n
                      uids=selection_uid_list, REQUEST=request)\n
\n
query_params = dict(portal_status_message=message)\n
if selection_name and not relation_found:\n
  query_params[\'selection_name\'] = selection_name\n
  query_params[\'selection_index\'] = selection_index\n
\n
\n
redirect_url = \'%s/%s?%s\' % (url, form_id, make_query(query_params))\n
return context.REQUEST[ \'RESPONSE\' ].redirect(redirect_url)\n
</string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>base_category, portal_type=(), related=1, selection_name="", selection_index=0, form_id=\'view\', target_form_id=None, jump_from_relative_url=None</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>8</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>base_category</string>
                            <string>portal_type</string>
                            <string>related</string>
                            <string>selection_name</string>
                            <string>selection_index</string>
                            <string>form_id</string>
                            <string>target_form_id</string>
                            <string>jump_from_relative_url</string>
                            <string>ZTUtils</string>
                            <string>make_query</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>Base_translateString</string>
                            <string>checkPerm</string>
                            <string>None</string>
                            <string>relation</string>
                            <string>append</string>
                            <string>$append0</string>
                            <string>_getiter_</string>
                            <string>x</string>
                            <string>getter_base_name</string>
                            <string>getattr</string>
                            <string>search_method</string>
                            <string>related_list</string>
                            <string>same_type</string>
                            <string>relation_found</string>
                            <string>len</string>
                            <string>url</string>
                            <string>_getitem_</string>
                            <string>unicode</string>
                            <string>message</string>
                            <string>related_object</string>
                            <string>module_id</string>
                            <string>get_uid_method</string>
                            <string>dict</string>
                            <string>related_object_list</string>
                            <string>path</string>
                            <string>obj</string>
                            <string>request</string>
                            <string>selection_uid_list</string>
                            <string>kw</string>
                            <string>query_params</string>
                            <string>_write_</string>
                            <string>redirect_url</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <tuple/>
                <int>1</int>
                <string></string>
                <int>0</int>
                <string>view</string>
                <none/>
                <none/>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Base_jumpToRelatedObject</string> </value>
        </item>
        <item>
            <key> <string>title</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
