Commit 530acb3d authored by Jean-Paul Smets's avatar Jean-Paul Smets

TempBase back home. context fixed


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1352 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 795fb8d5
......@@ -60,6 +60,7 @@ from string import join
import sys
import psyco
import pickle
import copy
from cStringIO import StringIO
from email.MIMEBase import MIMEBase
......@@ -1260,10 +1261,20 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana
# Context related methods
security.declarePublic('asContext')
def asContext(self, context=None, REQUEST=None, **kw):
# PERFORMANCE ISSUE
from Products.ERP5Type.Context import newContext
if context is None:
return newContext(context=self, REQUEST=REQUEST, **kw)
# Make a copy
context = self.__class__(self.getId())
context.__dict__.update(self.__dict__)
# Copy REQUEST properties to self
if REQUEST is not None:
context.__dict__.update(REQUEST)
# Define local properties
if kw is not None: context.__dict__.update(kw)
# Make it a temp content
for k in ('isIndexable', 'reindexObject', 'recursiveReindexObject', 'activate', 'setUid', ):
setattr(context, k, getattr(TempBase,k))
# Return result
return context.__of__(self)
else:
return context.asContext(REQUEST=REQUEST, **kw)
......@@ -1464,6 +1475,8 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana
local_permission_list = (local_permission_list,)
setattr(self,permission_name,tuple(local_permission_list))
InitializeClass(Base)
class TempBase(Base):
"""
If we need Base services (categories, edit, etc) in temporary objects
......@@ -1474,11 +1487,11 @@ class TempBase(Base):
def reindexObject(self, *args, **kw):
pass
def recursiveReindexObject(self, *args, **kw):
pass
def activate(self):
return self
def setUid(self, value):
self.uid = value # Required for Listbox so that no casting happens when we use TempBase to create new objects
InitializeClass(Base)
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