[Zope-CMF] Re: Monkey patching doesn't seem to work

Yuppie schubbe@web.de
Thu, 20 Mar 2003 08:54:48 +0100


Hi Suresh!


suresh_vv wrote:
> Here is the code in my __init__.py
> 
> ------------------------------------------
> from Products.CMFCore import PortalFolder
> from Products.CMFCore.CMFCorePermissions import View
> 
> def mySearchableText(self):
>     "Returns a concatination of all searchable text"
>     # Should be overriden by portal objects
>     return "%s %s" % (self.Title(), self.Description())
> 
> PortalFolder.security = ClassSecurityInfo() 
> PortalFolder.security.declareProtected(View, 'SearchableText') 
> PortalFolder.SearchableText = mySearchableText
> 
> InitializeClass(PortalFolder)
> -------------------------------------------
> 
> If I add SearchableText as a method to PortalFolder.py in CMFCore,
> then everything works!
> 
> Any ideas? Can someone verify the same?

I can't verify that. I did copy'n'paste your code in my __init__.py and 
SearchableText works.

If you add a Python script like this to your portal folder, what does it 
return if you test it?

<code>
print context.SearchableText()
return printed
</code>

If this returns your Title and Description, you've got a (re)indexing 
problem.

If not: Did you restart Zope? Refresh and monkey patch don't like each 
other very much.


HTH,

Yuppie