Paul Winkler wrote at 2005-5-27 16:28 -0400:
On Tue, May 24, 2005 at 08:59:01PM +0200, Dieter Maurer wrote:
An incredibly long time ago, I filed a feature request for
hasattr_unacquired -- together with patch, unit tests and documentation
update.
Do you mean this?
On Saturday 28 May 2005 01:26 am, Dieter Maurer wrote:
Paul Winkler wrote at 2005-5-27 11:08 -0400:
On Fri, May 27, 2005 at 03:26:04PM +0200, Dieter Maurer wrote:
A higher risk comes from the fact that some Python packages may
rely on the broken hasattr behaviour. That's the reason why
the
Paul Winkler wrote at 2005-5-27 11:08 -0400:
On Fri, May 27, 2005 at 03:26:04PM +0200, Dieter Maurer wrote:
A higher risk comes from the fact that some Python packages may
rely on the broken hasattr behaviour. That's the reason why
the problem is not fixed in Python itself.
And that's a very
Paul Winkler wrote:
marker = ()
if getattr(some_object, marker) is not marker:
For good measure, I wonder if that should be a [], no a ()?
cheers,
Chris
--
Simplistix - Content Management, Zope Python Consulting
- http://www.simplistix.co.uk
On Fri, May 27, 2005 at 08:51:58AM +0100, Chris Withers wrote:
Paul Winkler wrote:
marker = ()
if getattr(some_object, marker) is not marker:
For good measure, I wonder if that should be a [], no a ()?
What's wrong with a tuple? There's no reason to mutate the marker.
--
Paul Winkler
Paul Winkler [EMAIL PROTECTED] wrote:
On Fri, May 27, 2005 at 08:51:58AM +0100, Chris Withers wrote:
Paul Winkler wrote:
marker = ()
if getattr(some_object, marker) is not marker:
For good measure, I wonder if that should be a [], no a ()?
What's wrong with a tuple? There's no
Paul Winkler wrote at 2005-5-27 05:07 -0400:
...
What's wrong with a tuple? There's no reason to mutate the marker.
The Python spec allows implementations to identify immutable objects
with the same value. Thus, in principle, two () created
at different times can in fact be the same object.
Paul Winkler wrote at 2005-5-26 19:57 -0400:
...
Make it so! :-)
_marker = []
def hasattr(obj, attr, marker):
I introduced a bug here (noticed by Alec Mitchell).
The marker argument should have been _marker=_marker.
...
Are you currently running zope with a patch like this?
On Fri, May 27, 2005 at 01:58:44PM +0200, Florent Guillaume wrote:
And all empty tuples are equal.
Not just equal, but all empty tuples are *identical*,
so () is () == True.
I had no idea this was so :-\
In python 2.3, the idiom most commonly found is to use marker = object().
Thanks for
On Fri, May 27, 2005 at 03:26:04PM +0200, Dieter Maurer wrote:
A higher risk comes from the fact that some Python packages may
rely on the broken hasattr behaviour. That's the reason why
the problem is not fixed in Python itself.
And that's a very good reason not to monkeypatch it.
We can't
On Tue, May 24, 2005 at 08:59:01PM +0200, Dieter Maurer wrote:
An incredibly long time ago, I filed a feature request for
hasattr_unacquired -- together with patch, unit tests and documentation
update.
Do you mean this?
http://www.zope.org/Collectors/Zope/742
the unit tests and docs are
Dieter Maurer wrote:
By the way, it is as nasty in Python as it is in DTML.
I agree with we disagree, I hopethat doesn't cause offence ;-)
Worse still, you use hasattr with ZODB... hastattr swallows all
exceptions, including ConflictErrors, and especially in this example
that would be a bad
On Wed, May 25, 2005 at 09:03:13PM +0100, Chris Withers wrote:
if getattr(thefolder.aq_inner.aq_explicit,the_id,None):
You are aware that this is in general *NOT* an emulation
of hasattr.
I didn't say it was ;-)
It may fail e.g. for properties.
How would it fail for properties?
Well, it doesn't distinguish between an attribute which doesn't exist
and an attribute which has any false value. This makes it unsuitable as
a hasattr() replacement IMHO.
But you're asking if the object posesses an attribute, not any
question about the value of the object. I think returning
On Fri, May 27, 2005 at 09:20:52AM +1200, Phillip Hutchings wrote:
Well, it doesn't distinguish between an attribute which doesn't exist
and an attribute which has any false value. This makes it unsuitable as
a hasattr() replacement IMHO.
But you're asking if the object posesses an
On 27/05/05, Paul Winkler [EMAIL PROTECTED] wrote:
On Fri, May 27, 2005 at 09:20:52AM +1200, Phillip Hutchings wrote:
Well, it doesn't distinguish between an attribute which doesn't exist
and an attribute which has any false value. This makes it unsuitable as
a hasattr() replacement
Chris Withers wrote at 2005-5-25 21:03 +0100:
...
I strongly argue against it. Fix hasattr in the Zope context,
instead!
Make it so! :-)
_marker = []
def hasattr(obj, attr, marker):
a = getattr(obj, attr, _marker)
return a is not _marker
import
On Thursday 26 May 2005 02:52 pm, Dieter Maurer wrote:
Chris Withers wrote at 2005-5-25 21:03 +0100:
...
I strongly argue against it. Fix hasattr in the Zope context,
instead!
Make it so! :-)
I'd add the ability to turn on/off acquisition (off by default, import aq_base
somewhere
On Thu, May 26, 2005 at 11:52:36PM +0200, Dieter Maurer wrote:
Chris Withers wrote at 2005-5-25 21:03 +0100:
...
I strongly argue against it. Fix hasattr in the Zope context,
instead!
Make it so! :-)
_marker = []
def hasattr(obj, attr, marker):
a = getattr(obj,
Chris Withers wrote at 2005-5-23 20:02 +0100:
Dieter Maurer wrote:
Here is the problem. I want to use a form to upload a file (with a specific
name) but first I want to check if another file with the same name already
exist in that folder. How do I use a if or dtml-if to solve this problem??
Please stay on the list!
Readded...
Allen Huang wrote at 2005-5-8 11:10 -0700:
Thanks for responding, but what is aq_inner.aq_explicit??
To understand aq_inner and aq_explicit, you need
to understand acquisition.
You find something in the Name lookup section of
Here is the problem. I want to use a form to upload a file (with a specific name)but first I want to check ifanother file with the same name already exist in that folder. How do I use a if or dtml-if to solve this problem??
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail
Allen Huang wrote at 2005-5-8 02:28 -0700:
Here is the problem. I want to use a form to upload a file (with a specific
name) but first I want to check if another file with the same name already
exist in that folder. How do I use a if or dtml-if to solve this problem??
dtml-if
23 matches
Mail list logo