[Zope-dev] urg

Michel Pelletier michel@digicool.com
Tue, 07 Mar 2000 02:59:56 -0800


Tom,

You do not import the CatalogAware class, you import the
CatalogAwareness module.  The CatalogAware class is contained in the
CatalogAwareness module but python does not know this unless you
explicitly import what you explicitly try and use.  Thus, the
CatalogAware class is not defined any any of your namespaces and you get
a NameError.  Either:

from CatalogAwareness import CatalogAware

Or:

CatalogAwareness.Catalog.manage_afterAdd(self, item, container)

-Michel

Tom Deprez wrote:
> 
> Thanks for the reply James,
> 
> I do import the ClassAwareness library, but perhaps here is the mistake.
> Here is my full python script (and my first).
> 
> import sys
> sys.path.append('usr/local/zope/lib/python/Products/ZCatalog')
> import CatalogAwareness
> """ CatalogAwareness contains the CatalogAware Class """
> 
> def manage_afterAdd(self,item,container)
>     item.myparent=container.id
>     CatalogAware.manage_afterAdd(self,item,container)
>     return
> 
> I also tried this, but it always gives the same error :
> 
> def manage_afterAdd(self,item,container)
>     import sys
>     sys.path.append('usr/local/zope/lib/python/Products/ZCatalog')
>     import CatalogAwareness
> 
>     item.myparent=container.id
>     CatalogAware.manage_afterAdd(self,item,container)
>     return
> 
> Thanks, Tom.
> 
> At 17:47 07/03/2000 +0800, James Henstridge wrote:
> >This may be a silly question, but have you imported CatalogAware from
> >wherever it is defined, into the file where where the external method is?
> >If not, try doing that.
> >
> >James.
> >
> >--
> >Email: james@daa.com.au
> >WWW:   http://www.daa.com.au/~james/
> >
> >
> >On Tue, 7 Mar 2000, Tom Deprez wrote:
> >
> >> def manage_afterAdd(self,item,container)
> >>    item.myparent=container.id
> >>    CatalogAware.manage_afterAdd(self,item,container)
> >>    return
> >>
> >> But then I get following error when adding an instance of the new class :
> >>
> >> Zope Error
> >>
> >>            Zope has encountered an error while publishing this resource.
> >>
> >>            Error Type: NameError
> >>            Error Value: CatalogAware
> >>
> >>            Troubleshooting Suggestions
> >>
> >>                 This resource may be trying to reference a nonexistent
> >> object or variable
> >>                 CatalogAware.
> >>                 The URL may be incorrect.
> >>                 The parameters passed to this resource may be incorrect.
> >>                 A resource that this resource relies on may be encountering
> >> an error.
> >>
> >>
> >> Urgh, I'm really desperate. Do you know what I'm doing wrong?
> >>
> >> ps. Why does this function has to be an external method? Is it also
> >> possible with an DTML method?
> >>
> >> Regards, Tom.
> >
> >
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )