put python script in other directory.
Diretory stucture is root --subdir1 --ssubdir1 --ssubdir2 --dev --mydev I need to search some Zobject in subdir1 from diretory mydev. following python scirpt works if i put it in sundir1 [code] from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE catalog =container if not type: type = ['Units', 'UnitHeadquarter', 'SupervisoryUnit'] query = {} query['TemplateType'] = type if Unit: query['id'] = Unit query['sort_on'] = 'Title' results = catalog.searchResults(query) return results [/code] The problem is that i have not right to put scirpt in subdir1 i one can put script in dev->mydev [code] from Products.PythonScripts.standard import html_quote request = root.subdir1.REQUEST RESPONSE = request.RESPONSE catalog =root.subdir1 if not type: type = ['Units', 'UnitHeadquarter','SupervisoryUnit'] query = {} query['TemplateType'] = type if Units query['id'] = Unit query['sort_on'] ='Title' results =catalog.searchResults(query) return results [/code] But this way does not work, how can i change the script so i can put in in mydev and be able to search Zobjects in subdir1? Thanks
Jianping Zhu wrote:
Diretory stucture is root --subdir1 --ssubdir1 --ssubdir2 --dev --mydev
I need to search some Zobject in subdir1 from diretory mydev.
Let acquisition work for you. Remember that 'context.subdir1.ssubdir1' works fine from 'mydev'. Your root method would work if 'root' were a bound name in Python scripts. It's not. Did Zope not tell you this when you tried to run the method? If you want to find the root, there are several methods: see the very nice ZopeLabs recipe for this. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
Jianping Zhu wrote at 2003-12-4 18:16 -0500:
Diretory stucture is root --subdir1 --ssubdir1 --ssubdir2 --dev --mydev
I need to search some Zobject in subdir1 from diretory mydev.
"restrictedTraverse" may be the route to go. -- Dieter
participants (3)
-
Dieter Maurer -
J. Cameron Cooper -
Jianping Zhu