[Zope] Acquisition not working as expected

Roman Klesel roman_plonemail at lotuseyes.de
Thu Mar 2 02:13:52 EST 2006


Dieter Maurer schrieb:
>>I can call this method on whatever folder inside the product instance I want, it will always return the id of the
>>product and not the id of the product I call it on.
> 
> 
> I fear you will need to more clearly describe what you mean
> with "the product" (on one hand) and "the product I call it on"
> (on the other hand).

Yes sorry I got this wrong. The sentence should be like that:

I can call this method on whatever folder inside the product instance (instance of the base class ZLTMS) I want, it will
always return the id of the instace of the base class (where the method is defined) and not the id of the object (Folder
object or File object) I call it on.

Once again:

The module that holds the base class looks like this:

__doc__="""Das ist ZLMTS"""
__version__='0.1'

from Globals import InitializeClass, Persistent
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
from Acquisition import Implicit
from OFS.SimpleItem import SimpleItem
from OFS.PropertyManager import PropertyManager
from OFS.ObjectManager import ObjectManager
from OFS.Folder import Folder
from Lasttest import Lasttest

manage_addZLTMSForm=PageTemplateFile('zpt/manage_addZLTMSForm',globals())

							
def manage_addZLTMS(self,id,title='',REQUEST=None,submit=None):
	"Add a ZLMTS to a folder."

	id=id.replace(' ','_')
	#Jetzt wird das Product als Instanz erzeugt ...
	zltmsObj=ZLTMS(id,title)
	#... und persitiert
	id=self._setObject(id, zltmsObj)
	folder=getattr(self, id)
	#Create a container for the Loadtests
	folder.manage_addFolder(id='LoadTests',title='Collection')

	#irgned ein WODOO falls jemand das PRoduct programmatisch hinzufuegt.
	if REQUEST is not None:
		try:
			destURL=self.DestinationURL()
		except:
			destURL=REQUEST['URL1']

	REQUEST.RESPONSE.redirect(destURL+'/manage_main')			
	return ''


class ZLTMS(Lasttest,Implicit, Persistent, PropertyManager, ObjectManager, SimpleItem):
	"""ZLMTS object"""
	
	security = ClassSecurityInfo()
	meta_type = 'ZLMTS'

	manage_options = ObjectManager.manage_options + (
		             {'label' : 'View', 'action' : ''},
					 {'label' : 'Settings', 'action' : 'manage_editSettingsForm'},
					 ) + PropertyManager.manage_options + SimpleItem.manage_options
	
	_properties=({'id':'title','type':'string','mode':'w'},
				 {'id':'description','type':'text','mode':'w'},
				 )

	
	def __init__(self, id, title='', description='' ):
		"initialise a new instance of ZLMTS"
		self.id=id
		self.title=title
		self.description=description
		self.location_types=['http','path']
		self.manage_targets={'gr_sys' : {'name' : '',
										 'phy_mem' : '',
										 'location_sar' : '',
										 'grinder_home' : '',
										 'server_start_url' : ''},
							 'sys1' : {'name' : '',
									   'phy_mem' : '',
									   'location_sar' : '',
									   'server_start_url' : ''}}

and so on ...


More information about the Zope mailing list