[mod_python] Publisher and basic Python builtin types.

Graham Dumpleton grahamd at dscpl.com.au
Thu Feb 17 16:37:54 EST 2005

When using mod_python.publisher, it is possible to access both callable 
and basic types. That is, for a callable object, such as a function, it 
execute it and pass to it any form parameters which match the function 
If access is to a basic type, it will convert the data into a string 
and return

In the latter case for basic types, it means one could define a 
complete HTML
page as:

   index = "<html>...</html>"

Apart from string types, does anyone in the way they use 
publish other basic types such as integers, floats, tuples, lists, 
dictionaries etc?

Apart from debugging purposes perhaps, I can't see any reason why one 
would have
a valid reason to publish other builtin types, since the result would 
be a plain
text page holding only the string representation of that type as 
displayed by
Python. I don't see this as any practical value in an application.

Similarly, when a callable object is executed, any result will be 
converted to
a string and displayed as is as well. Thus, returning anything but a 
string will
similarly not yield anything that might be that useful.

Anyone want to prove me wrong and describe any valid practical reasons 
for publishing
of other basic types besides strings, or returning from a method 
anything but a

Oh, can we ignore for now instances of old or new style classes which 
may have
__str__ or __repr__ methods, am only interested in basic Python builtin 
types. :-)

Hopefully someone can satisfy my curiosity of what is common practice 
and what

Thanks in advance.


More information about the Mod_python mailing list