[Erp5-report] r16921 - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplateItem/p...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Oct 10 06:52:07 CEST 2007


Author: rafael
Date: Wed Oct 10 06:52:06 2007
New Revision: 16921

URL: http://svn.erp5.org?rev=16921&view=rev
Log:
Added a variation of Base_edit. This script was created by Romain for solve one edition problem for Planning Box.

The Problem was:

When you have the Planning Box for any Module and consider the user does not have modify permission on the module, it was not be possible to edit the planning box (blocs represent other objects not the module).

If If there is wrong, missing or missunderstood with this commit, please let me know.

Added:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_editUnrestricted.xml
Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision

Added: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_editUnrestricted.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_editUnrestricted.xml?rev=16921&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_editUnrestricted.xml (added)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_editUnrestricted.xml Wed Oct 10 06:52:06 2007
@@ -1,0 +1,377 @@
+<?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 encoding="cdata"><![CDATA[
+
+from Products.Formulator.Errors import FormValidationError\n
+from Products.CMFActivity.Errors import ActivityPendingError\n
+\n
+request=context.REQUEST\n
+portal = context.getPortalObject()\n
+N_ = portal.Base_translateString\n
+\n
+# Use dialog_id if present, otherwise fall back on form_id.\n
+if dialog_id not in (\'\', None):\n
+  form_id = dialog_id\n
+\n
+# Get the form\n
+form = getattr(context,form_id)\n
+\n
+try:\n
+  # Validate\n
+  form.validate_all_to_request(request)\n
+except FormValidationError, validation_errors:\n
+  # Pack errors into the request\n
+  field_errors = form.ErrorFields(validation_errors)\n
+  request.set(\'field_errors\', field_errors)\n
+  # Make sure editors are pushed back as values into the REQUEST object\n
+  for f in form.get_fields():\n
+    field_id = f.id\n
+    if request.has_key(field_id):\n
+      value = request.get(field_id)\n
+      if callable(value):\n
+        value(request)\n
+  return form(request)\n
+\n
+def editListBox(listbox_field, listbox):\n
+  """ Function called to edit a listbox\n
+  """\n
+  if listbox is not None:\n
+    gv = {}\n
+    if listbox_field.has_value(\'global_attributes\'):\n
+      hidden_attributes = map(lambda x:x[0], listbox_field.get_value(\'global_attributes\'))\n
+      for k in hidden_attributes:\n
+        gv[k] = getattr(request, k, None)\n
+    for url, v in listbox.items():\n
+      v.update(gv)\n
+      context.restrictedTraverse(url).edit(**v)\n
+\n
+def editMatrixBox(matrixbox_field, matrixbox):\n
+  """ Function called to edit a Matrix box\n
+  """\n
+  if matrixbox is not None:\n
+    cell_base_id = matrixbox_field.get_value(\'cell_base_id\')\n
+    portal_type = matrixbox_field.get_value(\'cell_portal_type\')\n
+    getter_method = matrixbox_field.get_value(\'getter_method\')\n
+    if getter_method not in (None, \'\'):\n
+      matrix_context = getattr(context,getter_method)()\n
+    else:\n
+      matrix_context = context\n
+    if matrix_context is not None:\n
+      kd = {}\n
+      kd[\'portal_type\'] = portal_type\n
+      kd[\'base_id\'] = cell_base_id\n
+      gv = {}\n
+      if matrixbox_field.has_value(\'global_attributes\'):\n
+        hidden_attributes = [x[0] for x in matrixbox_field.get_value(\'global_attributes\')]\n
+        for k in hidden_attributes:\n
+          gv[k] = getattr(request, k, None)\n
+      if matrixbox_field.get_value(\'update_cell_range\'):\n
+        # Update cell range each time it is modified\n
+        lines = matrixbox_field.get_value(\'lines\')\n
+        columns = matrixbox_field.get_value(\'columns\')\n
+        tabs = matrixbox_field.get_value(\'tabs\')\n
+\n
+        column_ids = map(lambda x: x[0], columns)\n
+        line_ids = map(lambda x: x[0], lines)\n
+        tab_ids = map(lambda x: x[0], tabs)\n
+\n
+        # There are 3 cases\n
+        # Case 1: we do 1 dimensional matrix\n
+        # Case 2: we do 2 dimensional matrix\n
+        # Case 3: we do 2 dimensional matrix + tabs\n
+        cell_range = matrix_context.getCellRange(base_id = cell_base_id)\n
+        if (len(column_ids) == 0) or (column_ids[0] is None):\n
+          matrixbox_cell_range = [line_ids]\n
+          if cell_range != matrixbox_cell_range:\n
+            matrix_context.setCellRange(line_ids, base_id=cell_base_id)\n
+\n
+        elif (len(tab_ids) == 0) or (tab_ids[0] is None):\n
+          matrixbox_cell_range = [line_ids, column_ids]\n
+          if cell_range != matrixbox_cell_range:\n
+            matrix_context.setCellRange(line_ids, column_ids, base_id=cell_base_id)\n
+\n
+        else:\n
+          matrixbox_cell_range = [line_ids, column_ids, tab_ids]\n
+          if cell_range != matrixbox_cell_range:\n
+            matrix_context.setCellRange(line_ids, column_ids, tab_ids, base_id=cell_base_id)\n
+\n
+      for k,v in matrixbox.items():\n
+        # Only update cells which still exist\n
+        if matrix_context.hasInRange(*k, **kd):\n
+          c = matrix_context.newCell(*k, **kd)\n
+          if c is not None:\n
+            c.edit(**gv)  # First update globals which include the def. of property_list\n
+            if v.has_key(\'variated_property\'):\n
+              # For Variated Properties\n
+              value = v[\'variated_property\']\n
+              del v[\'variated_property\']\n
+              if gv.has_key(\'mapped_value_property_list\'):\n
+                # Change the property which is defined by the\n
+                # first element of mapped_value_property_list\n
+                # XXX May require some changes with Sets\n
+                key = gv[\'mapped_value_property_list\'][0]\n
+                v[key] = value\n
+            c.edit(**v) # and update the cell specific values\n
+          else:\n
+            return "Could not create cell %s" % str(k)\n
+        else:\n
+          return "Cell %s does not exist" % str(k)\n
+\n
+def parseField(f):\n
+  """\n
+   Parse given form field, to put them in\n
+   kw or in encapsulated_editor_list\n
+  """\n
+  k = f.id\n
+  v = getattr(request, k, MARKER)\n
+  if hasattr(v, \'edit\'):\n
+    # This is an encapsulated editor\n
+    # call it\n
+    encapsulated_editor_list.append(v)\n
+  elif v is not MARKER:\n
+    if k.startswith(\'my_\'):\n
+      # We only take into account\n
+      # the object attributes\n
+      k = k[3:]\n
+      # Form: \'\' -> ERP5: None\n
+      if v == \'\':\n
+        v = None\n
+      kw[k] = v\n
+\n
+# Some initilizations\n
+kw = {}\n
+encapsulated_editor_list = []\n
+MARKER = []\n
+message = N_("Data+Updated.")\n
+\n
+try:\n
+  # We process all the field in form and\n
+  # we check if they are in the request,\n
+  # then we edit them\n
+  for field in form.get_fields():\n
+    parseField(field)\n
+    if(field.meta_type == \'ListBox\'):\n
+      editListBox(field, request.get(field.id))\n
+    elif(field.meta_type == \'MatrixBox\'):\n
+      editMatrixBox(field, request.get(field.id))\n
+\n
+  # Maybe we should build a list of objects we need\n
+  # Update basic attributes\n
+  context.edit(REQUEST=request,**kw)\n
+  for encapsulated_editor in encapsulated_editor_list:\n
+    encapsulated_editor.edit(context)\n
+except ActivityPendingError,e:\n
+  message = N_("%s" % e)\n
+\n
+ignore_layout = int(ignore_layout)\n
+editable_mode = int(editable_mode)\n
+\n
+if not selection_index:\n
+  redirect_url = \'%s/%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s\' % (\n
+                                  context.absolute_url(),\n
+                                  form_id,\n
+                                  ignore_layout,\n
+                                  editable_mode,\n
+                                  message)\n
+else:\n
+  redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s\' % (\n
+                              context.absolute_url(),\n
+                              form_id,\n
+                              selection_index,\n
+                              selection_name,\n
+                              ignore_layout,\n
+                              editable_mode,\n
+                              message)\n
+\n
+return request[\'RESPONSE\'].redirect(redirect_url)\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>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>form_id, selection_index=0, selection_name=\'\', dialog_id=\'\', ignore_layout=0, editable_mode=1</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>6</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>form_id</string>
+                            <string>selection_index</string>
+                            <string>selection_name</string>
+                            <string>dialog_id</string>
+                            <string>ignore_layout</string>
+                            <string>editable_mode</string>
+                            <string>Products.Formulator.Errors</string>
+                            <string>FormValidationError</string>
+                            <string>Products.CMFActivity.Errors</string>
+                            <string>ActivityPendingError</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>request</string>
+                            <string>portal</string>
+                            <string>N_</string>
+                            <string>None</string>
+                            <string>getattr</string>
+                            <string>form</string>
+                            <string>validation_errors</string>
+                            <string>field_errors</string>
+                            <string>_getiter_</string>
+                            <string>f</string>
+                            <string>field_id</string>
+                            <string>value</string>
+                            <string>callable</string>
+                            <string>editListBox</string>
+                            <string>editMatrixBox</string>
+                            <string>MARKER</string>
+                            <string>kw</string>
+                            <string>encapsulated_editor_list</string>
+                            <string>parseField</string>
+                            <string>message</string>
+                            <string>field</string>
+                            <string>_apply_</string>
+                            <string>encapsulated_editor</string>
+                            <string>e</string>
+                            <string>int</string>
+                            <string>redirect_url</string>
+                            <string>_getitem_</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <int>0</int>
+                <string></string>
+                <string></string>
+                <int>0</int>
+                <int>1</int>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_editUnrestricted</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=16921&r1=16920&r2=16921&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision Wed Oct 10 06:52:06 2007
@@ -1,1 +1,1 @@
-519
+520




More information about the Erp5-report mailing list