First of all, what you want can be done, but it is not that easy. There are a couple problems with your design goal, some Zope's, some yours. Luckily, the alternative is *very* easy ('very' being a relative term here, basicly it means you don't have to re-engineer Zope). You probably know this, but when Zope is tooling down through objects is traverses them according to various rules. First, it does something special (we'll get to that), then it tries to find the next object in line by just seeing if the next object is a subobject of the current (getattr). If that fails it tries to get the next objects as a sub-item of the current (getitem). If that fails, then it gives you a 404 telling you it couldn't find the next element in the URL you provided (you being the client). The special thing it does is it calls __bobo_traverse__. This is a special method. So you override the root level folder's __bobo_traverse__ to see if your 'virtual folder' is a user and then proceed from there. This is the problem: 1) You can't override the root level folder, because it's not a folder, really, it's the entire Zope application and 2) we override it allready so we beat you to it. Further, although simple, I think you will come to hate having all of your users in your root folder namespace. Generally, you want to keep this namespace as unclutered as possible for many reasons. One good reason is that everything in the root folder is acquireable by everything else, so it's 'prime real estate' in Zope. Another is what if one of your users wants to be named index_html? Or rss? Your __bobo_traverse__ method will either have to know all the special names you want priority on and do the users second, or whatever. Complex. Prone to error. What you really want is this: mysite.com/Users/Fred/rss So you need a special object, in this case instanciated with the id 'Users', that takes the next argument in line as a key into a database, and doesn't break acquisition paths along the way and lets you do this fancy URL manipulation. This special object can have a much simpler __bobo_traverse__ method, because it's not also trying to deal with other objects in the same namespace, the 'Users' namespace is dedicated solely to serving these virtual path elements. This special object should also be very generic, not database specific, and should be programmable directly with various SQL code to execute the query you want. This special object allready exists and does everthing you want to do, it's called a ZSQL Method. ZSQL Methods can accept arguments in the URL, and maintain acquisition so you can apply results to 'higher' objects. In fact, you can even chain ZSQL methods together to do multiple database look ups. Lets say you had two ZSQL Methods in the root folder named 'Users' and 'Flavor'. You can now do: mysite.com/Users/Fred/Flavor/Cherry/rss Users traverses 'Fred' as an argument, then *acquires* Flavor, which applies Cherry as a argument, then acquires rss. Nifty eh? -Michel Ian Sparks wrote:
Have been reading the docs but still not clear on a few things.
I have my site mapped out in my mind. It has URL's like :
mysite.com/ (main page) mysite.com/rss (rss content for mysite) mysite.com/<username> (main <username> page) mysite.com/<username>/rss (rss news content feed for <username> page)
Where I come from data belongs in a database. I'm happy for all my HTML to be in the ZopeDB but not any application data (users definitions, news items etc etc).
So, looking at my URLs I see that there are a mixture of static and virtual folders.
mysite.com/index_html is obviously static though it contains dynamic content. Doing this with Zope is easy and obvious.
mysite.com/Fred/ is a dynamic page. Fred only exists as a username in a users table and related information in other tables. It's not obvious to me how I go about serving this page because I can't create a static page for every username (nor do I want to).
Clearly mysite.com/Fred/rss will use almost identical processing to the mysite.com/rss page, just different parameters so re-using my "rss" generating code is important to me too.
I'm know these virtual folders can be served up by Zope. Can someone tell me what I am missing?
- Ian Sparks.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )