Specialists and __bobo_traverse__
I'm still lost as to when __bobo_traverse__ is checked for object traversal and when not. I have very simple piece of SkinScript: WITH SELF COMPUTE __bobo_traverse__ = traversal_method. Looking at the traverse method in BaseRequest.py it looks to me as if an object is always checked if it has a __bobo_traverse__ method but this is not what is happening. If I manually type in a url, say path.to.specialist/dataskin1, where dataskin1 exists, my traversal_method is not called. When I type in path.to.specialist/dataskin2, where dataskin2 does not exist then my traversal_method is called. Noticing that the traversal_method is called when an object can not be found I tried path.to.specialist/dataskin1/dataskin2, where dataskin1 is in the specialist's rack but dataskin2 is in another specialist's rack and will therefor not be found. In this case my traversal_method was not called. If it was then I could retrieve it from the appropriate specialist. I hope the above is clear because I'm somewhat desperate at the moment. If I'm trying the impossible, a simple "forget about it" will also do. Roché
It sounds to me like you're trying to have SkinScript supply a bobo_traverse for the Specialist itself, and this you cannot do. (There are other ways to change a Specialist's bobo_traverse behavior, but SkinScript is not one of them.) The SkinScript you're doing is meaningful only if you want to go to specialist/skin1/something, in which case your traversal_method should be called to process "something". I don't have the slightest idea what you're trying to accomplish here - I probably missed the beginning of this thread. Do you want to change the way the specialist processes the string "dataskin1", or the way dataskin1 processes the URL component that comes next? Each requires a different approach. At 07:28 PM 1/16/01 +0200, Roch'e Compaan wrote:
I'm still lost as to when __bobo_traverse__ is checked for object traversal and when not.
I have very simple piece of SkinScript: WITH SELF COMPUTE __bobo_traverse__ = traversal_method. Looking at the traverse method in BaseRequest.py it looks to me as if an object is always checked if it has a __bobo_traverse__ method but this is not what is happening.
If I manually type in a url, say path.to.specialist/dataskin1, where dataskin1 exists, my traversal_method is not called. When I type in path.to.specialist/dataskin2, where dataskin2 does not exist then my traversal_method is called. Noticing that the traversal_method is called when an object can not be found I tried path.to.specialist/dataskin1/dataskin2, where dataskin1 is in the specialist's rack but dataskin2 is in another specialist's rack and will therefor not be found. In this case my traversal_method was not called. If it was then I could retrieve it from the appropriate specialist.
I hope the above is clear because I'm somewhat desperate at the moment. If I'm trying the impossible, a simple "forget about it" will also do.
It sounds to me like you're trying to have SkinScript supply a bobo_traverse for the Specialist itself, and this you cannot do. (There are other ways to change a Specialist's bobo_traverse behavior, but SkinScript is not one of them.) The SkinScript you're doing is meaningful only if you want to go to specialist/skin1/something, in which case your traversal_method should be called to process "something".
This is exactly what I want to do ie. process "something".
I don't have the slightest idea what you're trying to accomplish here - I probably missed the beginning of this thread. Do you want to change the way the specialist processes the string "dataskin1", or the way dataskin1 processes the URL component that comes next? Each requires a different approach.
The best way to describe this is with an example I suppose. I have a specialist "Products" and nested within "Products" is another specialist "Modules". The current status quo: I go to a Product dataskin with a url like Products/<product_id>. I go to a Module dataskin with a url like Products/Modules/<module_id> Where I want to be: The url to the Product dataskin stays the same. I go to a Module dataskin with url like Products/<product_id>/<module_id> As I see it the <module_id> is like the "something" you mentioned above. The module dataskin would obviously not be found by the Products specialist, and in that case I simply want to tell it to go look in the Modules specialist for the module. I hope this makes more sense, if not I'll be glad to explain more. Many thanks Roché
I don't have the slightest idea what you're trying to accomplish here - I probably missed the beginning of this thread. Do you want to change the way the specialist processes the string "dataskin1", or the way dataskin1 processes the URL component that comes next? Each requires a different approach.
I want to process the way dataskin1 processes the URL component that comes next. Just to make sure I communicate some sense :) Roché
At 04:41 PM 1/17/01 +0200, Roch'e Compaan wrote:
I don't have the slightest idea what you're trying to accomplish here - I probably missed the beginning of this thread. Do you want to change the way the specialist processes the string "dataskin1", or the way dataskin1 processes the URL component that comes next? Each requires a different approach.
I want to process the way dataskin1 processes the URL component that comes next. Just to make sure I communicate some sense :)
Okay, then your SkinScript *should* work, so long as your dataskins don't already inherit a __bobo_traverse__ method. If your DataSkin inherits from ObjectManager or any of its derivatives, for example, then it won't work. Of course, the bobo_traverse you're supplying has to be able to be bound to the DataSkin. Not all types of Zope "method" objects can do this binding correctly. ZPublisher will call the method with two arguments, but your method will (presumably) need three: one of which is "self" - the DataSkin itself. I'm pretty sure DTML methods *won't* work. "Python Methods" might. I don't know about external methods, python scripts, etc. If I was trying to solve your problem, I would just write a __bobo_traverse__ in a Python base for my class. If I needed it to be replaceable on the fly, I'd write it so that it looked for another attribute, maybe __skin_traverse__, and called it if it existed. But I'd have it pass three parameters, including self, so that I could use almost any kind of Zope method and make it work. Then if I needed to customize it I could use SkinScript or a Class Extender to add the method in.
Phillip J. Eby wrote:
I'm pretty sure DTML methods *won't* work. "Python Methods" might. I don't know about external methods, python scripts, etc.
I have successfully used PythonScripts for this.
Does this mean I have to upgrade to 2.3 beta 1, because Python Methods on 2.2.4 doesn't work? Roché
Phillip J. Eby wrote:
I'm pretty sure DTML methods *won't* work. "Python Methods" might. I don't know about external methods, python scripts, etc.
I have successfully used PythonScripts for this.
Did you have to do anything special in setting up rights for your traversal method. I get: Unauthorized: You are not authorized to access <em>traversal_method</em>. Roché
At 04:45 PM 1/18/01 +0200, Roch'e Compaan wrote:
Phillip J. Eby wrote:
I'm pretty sure DTML methods *won't* work. "Python Methods" might. I don't know about external methods, python scripts, etc.
I have successfully used PythonScripts for this.
Did you have to do anything special in setting up rights for your traversal method.
I get:
Unauthorized: You are not authorized to access <em>traversal_method</em>.
See the message I just posted on "skinscript and URL traversal question". Basically, your SkinScript may need to be given proxy role(s) to allow it to access traversal_method, since during URL traversal the user is not yet authenticated and thus has no rights unless proxy roles are applied.
participants (3)
-
Phillip J. Eby -
Roch'e Compaan -
Steve Alexander