[Zope] Attribute error __call__
Marie Robichon
robichon@esrf.fr
Fri, 28 Jun 2002 13:48:46 +0200
--=====================_18396188==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
hi everyone,
I am working on a treemenu based on Mike Renfro's 'new generation sitemap'
and have modified slightly the scripts to do some extra filtering of the
objects before they are added to the treemenu. In the script that finds
child folders I have added a call to a script onsiteCheck that checks
whether the request comes from onsite or from internet and if it
has certain attribute or property, this works fine (see below)
## Script (Python) "list_child_folders"
##
# Find child folders of the current without a sitemap property
results=[]
ids=[]
for object in context.REQUEST.PARENTS[0].objectIds(['Folder', 'Page
Container']):
item=getattr(context, object)
if item.onsiteCheck()=="yes":
ids.append(object)
for id in ids:
object=getattr(context, id)
if hasattr(object.aq_explicit, 'siteMap'):
results.append(object)
return results
However when I try to do the same in the list_sibling_folders, I get an
AttributeError __call__
File
/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Products/PythonScripts/PythonScript.py,
line 302, in _exec (Object: onsiteCheck) (Info: ({'script': <PythonScript
instance at 16ed4d8>, 'context': <Folder instance at 1c4f7a0>, 'container':
<Folder instance at 108f478>, 'traverse_subpath': []}, (), {}, None)) File
Script (Python), line 7, in onsiteCheck
Here is the list_sibling_folders script
# Find sibling folders within the current folder with a sitemap property
results=[]
ids2=[]
if len(context.REQUEST.PARENTS)>1:
for object in context.REQUEST.PARENTS[1].objectIds(['Folder', 'Page
Container']):
item=getattr(context, object)
if item.onsiteCheck()=="yes":
ids2.append(object)
for id in ids2:
object=getattr(context, id)
if hasattr(object.aq_explicit, 'siteMap'):
results.append(object)
return results
and here is the onsiteCheck script (not very well written, but still....)
"""
Script used for the 'new generation sitemap': checks each item of the top,
parent,
child and sibling scripts for publishOffsite properties or attributes
(called in these scripts)
MR 27/6/02
"""
if context.Location() != 'internet':
return "yes"
elif context.meta_type=='Folder':
if (context.hasProperty('publishOffsite')
and (context.getProperty('publishOffsite')=="on")):
return "yes"
elif context.meta_type=='Page Container':
if (hasattr(context, 'publishOffsite') and (getattr(context,
'publishOffsite')=="on")):
return "yes"
Can anyone help please?
Thanks
Marie Robichon
Web Task Force
European Synchrotron Radiation Facility
BP 220
38043 Grenoble Cedex
France
http://www.esrf.fr
Tel: (33) 04 76 88 21 86
Fax: (33) 04 76 88 24 27
--=====================_18396188==_.ALT
Content-Type: text/html; charset="us-ascii"
<html>
hi everyone,<br>
<br>
I am working on a treemenu based on Mike Renfro's 'new generation
sitemap' and have modified slightly the scripts to do some extra
filtering of the objects before they are added to the treemenu. In
the script that finds child folders I have added a call to a script
onsiteCheck that checks whether the request comes from onsite or
from internet and if it has certain attribute or property, this
works fine (see below)<br>
<br>
<font face="Courier New, Courier">## Script (Python)
"list_child_folders"<br>
##<br>
# Find child folders of the current without a sitemap property<br>
results=[]<br>
<br>
ids=[]<br>
for object in context.REQUEST.PARENTS[0].objectIds(['Folder', 'Page
Container']):<br>
item=getattr(context, object)<br>
if item.onsiteCheck()=="yes":<br>
ids.append(object)<br>
<br>
for id in ids:<br>
object=getattr(context, id)<br>
if hasattr(object.aq_explicit, 'siteMap'):<br>
results.append(object)<br>
<br>
return results<br>
<br>
<br>
</font>However when I try to do the same in the list_sibling_folders, I
get an AttributeError __call__<br>
<br>
File
/zope/Zope-2.5.0-solaris-2.6-sparc/lib/python/Products/PythonScripts/PythonScript.py,
line 302, in _exec (Object: onsiteCheck) (Info: ({'script':
<PythonScript instance at 16ed4d8>, 'context': <Folder instance
at 1c4f7a0>, 'container': <Folder instance at 108f478>,
'traverse_subpath': []}, (), {}, None)) File Script (Python), line 7, in
onsiteCheck <br>
<br>
Here is the list_sibling_folders script<br>
<br>
# Find sibling folders within the current folder with a sitemap
property<br>
<br>
results=[]<br>
<br>
ids2=[]<br>
if len(context.REQUEST.PARENTS)>1:<br>
for object in context.REQUEST.PARENTS[1].objectIds(['Folder',
'Page Container']):<br>
item=getattr(context, object)<br>
if item.onsiteCheck()=="yes":<br>
ids2.append(object)<br>
<br>
for id in ids2:<br>
object=getattr(context, id)<br>
if hasattr(object.aq_explicit, 'siteMap'):<br>
results.append(object)<br>
<br>
return results<br>
<br>
and here is the onsiteCheck script (not very well written, but
still....)<br>
<br>
"""<br>
Script used for the 'new generation sitemap': checks each item of the
top, parent, <br>
child and sibling scripts for publishOffsite properties or attributes
(called in these scripts)<br>
MR 27/6/02<br>
"""<br>
<br>
if context.Location() != 'internet':<br>
return "yes"<br>
elif context.meta_type=='Folder':<br>
if (context.hasProperty('publishOffsite') and
(context.getProperty('publishOffsite')=="on")):<br>
return "yes"<br>
elif context.meta_type=='Page Container':<br>
if (hasattr(context, 'publishOffsite') and (getattr(context,
'publishOffsite')=="on")):<br>
return "yes"<br>
<br>
Can anyone help please?<br>
<br>
Thanks<br>
<br>
<br>
<br>
<br>
<div>Marie Robichon</div>
<br>
<div>Web Task Force</div>
<div>European Synchrotron Radiation Facility</div>
<div>BP 220</div>
<div>38043 Grenoble Cedex</div>
<div>France</div>
<br>
<div><a href="http://www.esrf.fr/" EUDORA=AUTOURL>http://www.esrf.fr</a></div>
<br>
<div>Tel: (33) 04 76 88 21 86</div>
Fax: (33) 04 76 88 24 27
</html>
--=====================_18396188==_.ALT--