[Zope] getting the type of an object from within dtml ???

Rik Hoekstra rik.hoekstra@inghist.nl
Mon, 26 Jun 2000 10:08:52 +0200


> >> would you please elaborate.... what are you trying to determine the
> type of?
> 
> Sorry for my lack of clarity.
> 
> I would like to get the class of the object, just using dtml. (and
> without using external method)
> 
> Typically, the idea would be to define a dtml method (for instance
> getclass) that return the class
> of the object, so that I could write:
> 
> --- in a dtml-method defined for a Class A, and that can be called
> from instance
> of class A or subclasses of A.
> ...
> <br>My class is :<dtml-var getclass>

If you call an object like so <dtml-var "<yourobject>">, without
parenthesis, in the source it will give you what you want. It is just
that Python returns it like <instance of yourobject at ...>. Because
it's like a html tag, it will only show in the source of your object. If
this is the information you want, you should find a way of escaping the
< and >. You might use and external method for this (calling this
getclass perhaps).

Otherwise, the meta-type is the best solution, as these are unique for
classes anyway. Most classes are called the same as their meta type
anyway.

> ...
> 
> >> Zope namespace ... eventually the namespace will be explained and
> documented better.
> 
> I believe this is not a matter of documentation.
> It is just that is is uselessly too complicate.
> 
> Note:
> I very much like some of the ideas behind Zope. (such as the good
> integration
> of an OO database in the system, use of a dynamic language, etc.)
> But I can really not get used to some of the other aspects that are
> very well
> addressed by other systems, but are so poorly addressed by Zope such
> as:
>   * the namespace.

Yes this can be complicated, but most real complications are caused by
acquisition, which is one of the main Zope features. What is a pain, is
the way of handling namespaces in DTML. But   DTML wasn't created for
that. I'm not entirely convinced changing to Python/External Methods  is
a much better solution to many problems, though.

>   * bad integration with python.

Zope as a whole is very tightly integrated with Python IMHO. 
You probably mean DTML integration with Python, which is true. You could
change to using PythonMethods, which (arguably) make complicated logic
easier. Or contribute to making DTML more Pythonish.

>   * can not change the inheritance tree once a class has been created.

Of a ZClass you mean. That's true. Changin classes inside a Python
Product shouldn't be too bad, however.

> 
>     (I have tried one of the trick that was posted somewhere, but it
> does not work 100%).
>   * very bad support for pointers (object1 --> object2).

Yes, that's true, though clever use of the Catalog might help you there
somewhat.

Rik