Inconsistent aquisition behavior between Zope versions
Hi, I had to spent some time out of this list and now I'm trying to upgrade to Zope2 and to catch on with all the news. Everything seems to work fine with my upgrade, but I'm with a problem with a site pattern I use a lot. I'll first describe the site design pattern I use with an example. I have a SQL method to get a list of cities, if an state_id variable is defined I just get the cities of that state. Here is the "getCities" SQL method: SELECT * FROM city <!--#if state_id--> WHERE state_id=<!--#var state_id--> <!--#/if--> It doens't have any arguments. I have a subfolder "state18" that is almost empty, it just defines an int property: state_id=18 When I test the sql method everything works fine. In the base folder the query returns all cities, if I add "state18" to the query url, the query just returns the cities of state number 18. The problem happens when I use the query inside a DTML document. If I have a DTML method "showCities" that list just list the cities and is inserted inside a document "cities". I get: In Zope 1.10.3: http://mysite.com/basefolder/cities => returns all cities http://mysite.com/basefolder/state18/cities => returns cities of state 18 In Zope 2 http://mysite.com/basefolder/cities => returns all cities http://mysite.com/basefolder/state18/cities => STILL returns all cities If I change the cities document to a method everything work as expected. If anyone want to test it, I can send simple example folders for Zope 1.10 and Zope 2. Any help? -- Paulo Eduardo Neves maito:neves@email.com Rio de Janeiro - Brasil
Paulo Eduardo Neves wrote:
Hi, I had to spent some time out of this list and now I'm trying to upgrade to Zope2 and to catch on with all the news. Everything seems to work fine with my upgrade, but I'm with a problem with a site pattern I use a lot.
I'll first describe the site design pattern I use with an example.
I have a SQL method to get a list of cities, if an state_id variable is defined I just get the cities of that state. Here is the "getCities" SQL method: SELECT * FROM city <!--#if state_id--> WHERE state_id=<!--#var state_id--> <!--#/if-->
It doens't have any arguments.
I have a subfolder "state18" that is almost empty, it just defines an int property: state_id=18
When I test the sql method everything works fine. In the base folder the query returns all cities, if I add "state18" to the query url, the query just returns the cities of state number 18.
The problem happens when I use the query inside a DTML document. If I have a DTML method "showCities" that list just list the cities and is inserted inside a document "cities". I get:
In Zope 1.10.3: http://mysite.com/basefolder/cities => returns all cities http://mysite.com/basefolder/state18/cities => returns cities of state 18
In Zope 2
http://mysite.com/basefolder/cities => returns all cities http://mysite.com/basefolder/state18/cities => STILL returns all cities
If I change the cities document to a method everything work as expected.
In Zope 1.x, all 'DTML Documents' where actually method objects. Then, there was no distinction because there were no document objects. They were just called 'Documents' because they had document like behavior. In late 1.10.2, we realized that the concept of 'Document' content should behave like an object, not a method, and that method like behavior of 'DTML Document' should be renamed to 'DTML Method'. This is a complete 180 degree concept change, and we appologize, but the distinction is much more powerful and flexible now, and also more complex, because you have two very similar objects. I suggest you read the DTML Documents vs. DTML Methods How-To: http://www.zope.org:18200/Members/michel/HowTos/DTMLMethodsandDocsHowTo or you can skip the next 50 lines and I'll give you the answer: DTML Documents are their own objects. In 1.x, DTML Documents were methods of the folder that contained them and are now called DTML Methods. DTML Methods do not have their own properties, the folder that contains them is the context that their DTML code is executed. DTML Documents on the other hand execute in their own context. Both 'objects' can contain DTML, text content, and be called in the context of a REQUEST namespace identically. The only difference is that a Method does not have it's own properties or 'self' identity, and Documents do. To get the expected behavior, change your Documents to Methods. -Michel
participants (2)
-
Michel Pelletier -
Paulo Eduardo Neves