RE: [Zope-dev] Specialists and __bobo_traverse__

2001-01-17 Thread Phillip J. Eby

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.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-17 Thread Steve Alexander

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.


--
Steve Alexander


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] Specialists and __bobo_traverse__

2001-01-17 Thread Roch'e Compaan


 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


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-16 Thread Phillip J. Eby

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.



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-16 Thread Roch'e Compaan

 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




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-15 Thread Steve Alexander

Roch'e Compaan wrote:

 Recent sightings of the use of __bobo_traverse__ in SkinScript gave me hope
 of giving users a more useable breadcrumbs trail in the case where I have
 nested specialists.
 
 My TaskTemplates specialist is nested inside my RequestTypes specialist.
 When I retrieve a dataskin from the RequestTypes specialist I have a tab
 that lists TaskTemplates for that RequestType specialist.  Following a link
 from the TaskTemplate list takes you to that instance.
 
 Thus results in a url like this:
   /RequestTypes/request type instance/Task Templates/task template
 instance,
 and what I ideally want is:
   /RequestTypes/request type instance/task template instance.
 
 I read all the comments about __bobo_traverse__ and created a python method,
 "traversal_method" inside the "RequestTypes" specialists.  I must admit that
 I don't really understand Zope's traversal machinery yet and would
 appreciate some guidance.

With your code below, and with a concrete example, can you say what you 
want to happen, and what actually does happen?

 My SkinScript for RequestTypes:
 
 WITH SELF COMPUTE __bobo_traverse_=traversal_method

You'll want another underscore in there: __bobo_traverse__

 My traversal_method:
 
 ob = getattr(self, name)
 if ob is not None:
return ob

If ob is not found, you'll get an error raised. You need to have some 
sort of marker for the default value.

marker=[]
ob=getattr(self, name, marker)
if ob is not marker:
   return ob
# continue your method

Of course, you only need one marker in your class. You can do that if 
you implement your method as an external method, or perhaps with a 
default value for an argument on you python method.

Or, you could not worry about creating a new empty list on each request.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Specialists and __bobo_traverse__

2001-01-15 Thread Chris Withers

Steve Alexander wrote:
 
 If ob is not found, you'll get an error raised. You need to have some
 sort of marker for the default value.

Is there any reason why no-one uses None as a marker?

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] Specialists and __bobo_traverse__

2001-01-15 Thread Roch'e Compaan


 With your code below, and with a concrete example, can you say what you
 want to happen, and what actually does happen?

  Thus results in a url like this:
  /RequestTypes/request type instance/Task Templates/task template
  instance,
  and what I ideally want is:
  /RequestTypes/request type instance/task template instance.

Let's say I have a RequestType called "Evaluation of Product".  For this
request type I create Task Templates called "Record Customer Details" and
"Ship Product to Customer".  If I go to the Request Type "Evaluation of
Product" the url is: path.to.requestypes/evaluation_of_product.  This gives
me the detail of the request type as well as the list of task templates
relating to this request type.  If I now follow the link to the task
template "Record Customer Details", I simply want to click on a url that
says path.to.requesttypes/evaluation_of_product/record_customer_details and
do not explicitly want to go the TaskTemplates with
path.to.requesttypes/evaluation_of_product/TaskTemplates/record_customer_det
ails.

In other words, my traversal_method for the RequestTypes specialist should
first seek the object on it's own rack and if it can not find it is should
ask the nested TaskTemplates specialist for the object.

Roch


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] Specialists and __bobo_traverse__

2001-01-15 Thread Roch'e Compaan


 With your code below, and with a concrete example, can you say what you
 want to happen, and what actually does happen?

In my traversal_method I have one line that simply changes a property on the
specialist to see if the method is actually called but it does not seem like
the traversal_method is called at all.  The skinscript I use (as said in my
previous mail) is:

WITH SELF COMPUTE __bobo_traverse__=traversal_method

Roch


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )