[Zope] Silly question

Dan Pozmanter dan at siteworx.com
Thu Jun 2 16:34:13 EDT 2005


The name could change easily enough.

How about __bobo_always_allow__

Which can either be:
None
A List of traversable items
A method that takes the path, and returns whether or not it is
traversable.

So for a path p:

if p[0] == '_':
	if p_object.__bobo_always_allow__:
      	if type(p_object.__bobo_always_allow__) is type([]):
      		if p in p_object.__bobo_always_allow__:
				#allow
			else:
				#Do what is normally done for '_' bits.
		else:
			if p_object.__bobo_always_allow__(p):
				#allow
			else:
				#Do what is normally done for '_' bits.	
	else:
      	#Do what is normally done for '_' bits.

Something vaguely like that.

That way you could either specify the exact items that start with '_',
or have a method determine it on the fly.

This way you would not automatically make all attributes that start with
an underscore
accessible, and the developer could specify exceptions.

-----Original Message-----
From: Chris McDonough [mailto:chrism at plope.com] 
Sent: Thursday, June 02, 2005 4:15 PM
To: Dan Pozmanter
Cc: zope at zope.org
Subject: Re: [Zope] Silly question

The DWIM of not disallowing traversal of underscore names is useful
(because it makes it easy to conventionally mark attrs as private) but
it can definitely be a drag if you really do want to publish something
that begins with an underscore; this happens a lot when you need to deal
with allowing uploads of arbitrary filenames.

It might be useful to add something like you propose, except I might
take exception to the name "isTraversable" (everything is traversable,
really); maybe just set a magic attr on the object like
__allow_underscore_traversal__.

However, adding such a feature would need to be done carefully.  Much
usage of the Zope security machinery utterly depends on not being able
to traverse underscore names.

- C

On Thu, 2005-06-02 at 15:59 -0400, Dan Pozmanter wrote:
> Wouldn't it be cool if instead of checking explicitly for a leading 
> '_' during traversal, you ran a method "isTraversable" (On SimpleItem 
> for instance), which by default just checks for a leading '_', but 
> could be overridden in a particular class?
>  
> Dan
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )



More information about the Zope mailing list