[Zope] acquisition angst - help pls.

chas panda@skinnyhippo.com
Sun, 05 Sep 1999 03:33:06 +0900


i thought i sort of understood acquisition but this one has me stumped.

/locations/index_html  contains this :

<dtml-var standard_html_header>
<dtml-var mtdBanner>
<dtml-var mtdCategoryListing>
<dtml-var standard_html_footer>

where mtdCategoryListing is a dtml method which formats the output
from a z sql method. the z sql method takes one argument "category".

now, if i run this with "/locations/index_html?category=hotels"
it works fine. but i don't like ever using those "?var=value&var2=value2"
urls.
it would be better to use "/locations/hotels" for the example above.

taking this one step further, to subcategories, "/locations/hotels/3star"
would be way better than
"/locations/index_html?category=hotels&subcategory=3star"

ok, so far ? 

so, to enable this, i created another folder   "/locations/Hotels"
and this folder has a property called "category" whose value is "hotels"

now, if i type in the URL "/locations/Hotels" there is no index_html in
the folder, so zope then goes up one directory to "/locations" and uses
"/locations/index_html"   and then several things go wrong :

a) the sql method called in mtdCategoryListing claims that there is no
   property called 'category'. how come it didn't pick it up from the
subfolder
   Hotels which was in the URL ?

b) worse, the dmtl method 'mtdBanner' in the index_html (see above) now
   bums out badly. it is actually in the root folder (ie. it is "/mtdBanner")
   and it's code is simple :
   <dtml-with "Images.Banner">
   .... loads of html and <dtml-var> expressions
   </dtml-with>
   when i was using "/locations/index_html?category=hotels" i had no 
   problems, but now using "/locations/Hotels", i get this error :
   
             Zope Error

             Zope has encountered an error while publishing this resource. 

             Error Type: AttributeError
             Error Value: __call__

File D:\Inetpub\Moo\lib\python\OFS\DTMLMethod.py, line 141, in __call__
    (Object: mtdBanner)
  File D:\Inetpub\Moo\lib\python\DocumentTemplate\DT_String.py, line 502,
in __call__
    (Object: mtdBanner)
  File D:\Inetpub\Moo\lib\python\DocumentTemplate\DT_With.py, line 148, in
render
    (Object: Images.Banner)
AttributeError: (see above)

   which looks like a namespace problem.


hoping somebody can help. either that or advise a better way to manage
this with more zope-zen. (my current method seems a bit of a pain in the 
butt creating all these folders for all the categories and subscategories...
and not as flexible for changes). eg. for the "Restaurants" category, i 
have 40 subcategories, each requiring a folder to get the value of 'subcat'. 
the price to pay for simpler URLs ? 

cheers,

chas