Commit dd102ec0 authored by Romain Courteaud's avatar Romain Courteaud

Unify RelationField and MultiRelationField (in order to fix both of them at the

same time).
Bug fix: do not write the relation_index in the ZODB anymore.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6202 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b9d9e7bf
...@@ -38,7 +38,6 @@ from urllib import quote ...@@ -38,7 +38,6 @@ from urllib import quote
from Globals import InitializeClass, PersistentMapping, DTMLFile, get_request from Globals import InitializeClass, PersistentMapping, DTMLFile, get_request
from AccessControl import Unauthorized, getSecurityManager, ClassSecurityInfo from AccessControl import Unauthorized, getSecurityManager, ClassSecurityInfo
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from Products.ERP5Type.Utils import UpperCase from Products.ERP5Type.Utils import UpperCase
import psyco import psyco
...@@ -111,6 +110,7 @@ def get_value(self, id, **kw): ...@@ -111,6 +110,7 @@ def get_value(self, id, **kw):
else: else:
# get normal value # get normal value
value = self.get_orig_value(id) value = self.get_orig_value(id)
# For the 'default' value, we try to get a default value # For the 'default' value, we try to get a default value
if id == 'default': if id == 'default':
if (value is None or value == '' or value == [] or value == ()) \ if (value is None or value == '' or value == [] or value == ()) \
...@@ -355,7 +355,6 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -355,7 +355,6 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
# Proxy method to PageTemplate # Proxy method to PageTemplate
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
self._v_relation_field_index = 0 # We initialize here an index which is used to generate different method ids for every field
if not kwargs.has_key('args'): if not kwargs.has_key('args'):
kwargs['args'] = args kwargs['args'] = args
form = self form = self
...@@ -370,6 +369,11 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -370,6 +369,11 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
extra_context['form'] = self extra_context['form'] = self
extra_context['container'] = container ## PROBLEM NOT TAKEN INTO ACCOUNT extra_context['container'] = container ## PROBLEM NOT TAKEN INTO ACCOUNT
extra_context['here'] = object extra_context['here'] = object
# We initialize here an index which is used to generate
# different method ids for every field
request = extra_context['request']
# XXX We must not use a counter, but a ID for each field
request.set('_v_relation_field_index', 0)
return pt.pt_render(extra_context=extra_context) return pt.pt_render(extra_context=extra_context)
def _exec(self, bound_names, args, kw): def _exec(self, bound_names, args, kw):
...@@ -456,6 +460,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -456,6 +460,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
# More optimizations # More optimizations
#psyco.bind(ERP5Field) #psyco.bind(ERP5Field)
# XXX Not useful, as we patch those methods in FormulatorPatch
psyco.bind(Field.render) psyco.bind(Field.render)
psyco.bind(Field._render_helper) psyco.bind(Field._render_helper)
psyco.bind(Field.get_value) psyco.bind(Field.get_value)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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