[Zope] Question about possible Data.fs corruption

Chris Withers lists at simplistix.co.uk
Wed Mar 10 09:10:00 EST 2004


Hi Ira,

Ira Sher wrote:

This is truly horrible code, and a good example of why DTML sux so bad:
> <dtml-in "Catalog.searchResults(meta_type='Book',sie='on')">
> and the dtml script writing the data is writing:
> <dtml-call "REQUEST.set('id','readers_guide')">
> <dtml-call "REQUEST.set('sie','on')">
> <dtml-with "Readers_Guide.createInObjectManager(REQUEST['id'], REQUEST)">
>  <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)">
>  <dtml-call 
> "aq_parent.propertysheets.Basic.manage_changeProperties(REQUEST)">
>  <dtml-call "reindex_object()">
>  <dtml-call "aq_parent.reindex_object()">
> </dtml-with>

Lets try the above again in a Script (Python):

REQUEST = context.REQUEST
# NB: no REQUEST polution from the following...
id = 'readers_guide'
sie = 'on'
for brain in Catalog.searchResults(meta_type='Book',sie='on'):
    # dunno what else you have in REQUEST, so leaving as is...
    rg = brain.Readers_Guide.createInObjectManager(id, REQUEST)
    # you're using ZClasses and editProperties - ouch!
    # I hope this method is
    # getting called from a web form which shows ALL the properties...
    rg.propertysheets.Basic.manage_editProperties(REQUEST)
    rg_container = rg.aq_parent
    # The following line makes no sense, what's it trying to change?
    rg_container.propertysheets.Basic.manage_changeProperties(REQUEST)
    rg.reindex_object()
    rg_container.reindex_object()

...which is still pretty croaky, but at least debuggable now.
I'd really want to get ride of those REQUEST's as arguments to 
createInObjectManager and the property changers...

> which would seem to set sie as "on", the newer records return sie as 
> True rather than "on", and so fail. 

Using the REQUEST in the way the above do is pretty dodgy...

> The version of python was updated on 
> the live server. Could this have caused the problem? 

Yes, if the properties are of type Boolean and you upgraded Zope as well..

> How can I be more 
> explicit in the call to ensure that "on" is preserved rather than 
> converted to True?

Don't use ZClasses? ;-) Well, look at the property sheets, see what version fo 
Zope was and is in use, etc...

cheers,

Chris - nothing beats a badly written Zope app (or perl) for pain and suffering.

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk




More information about the Zope mailing list