[Zope] Using Zclasses

Michel Pelletier michel@digicool.com
Tue, 6 Jul 1999 08:22:57 -0400


> -----Original Message-----
> From: Alexander Staubo [mailto:alex@mop.no]
> Sent: Monday, July 05, 1999 10:28 PM
> To: Zope Mailing List (E-mail); 'Michael Bernstein'
> Subject: RE: [Zope] Using Zclasses
> 
> 
> or something like that, assuming HasAttr() is an External Method that
> tests for the existence of a property (I have not found this
> functionality in Zope's built-in DTML API: The closest I you get is
> getattr, which raises an error if it fails). I implement this function
> like so::
> 
>   def HasAttr(o, attr):
>     return hasattr(o, attr)
> 

The _ namespace has a hasattr.  Quote DocumentTemplate/DT_Util.py:

  This variable also has attributes that provide access to standard
  utility objects.  These attributes include:
  
  - The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
       'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
       'round', and 'str' from the standard Python builtin module.

  - Special security-aware versions of 'getattr' and 'hasattr',
  
  - The Python 'string', 'math', and 'whrandom' modules, and
  
  - A special function, 'test', that supports if-then expressions.
    The 'test' function accepts any number of arguments.  If the
    first argument is true, then the second argument is returned,
    otherwise if the third argument is true, then the fourth
    argument is returned, and so on.  If there is an odd number of
    arguments, then the last argument is returned in the case that
    none of the tested arguments is true, otherwise None is
    returned. 
  


-Michel

> --
> Alexander Staubo             http://www.mop.no/~alex/
> "What the hell, he thought, you're only young once, and threw
> himself out of the window. That would at least keep the element of
> surprise on his side."
> --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>