[mod_python] objects as actions

Jean Martin jombo at 2wire.ch
Thu Aug 26 23:23:21 EDT 2004


Hi,

If i understand good what you are trying to do the code will be :

from mod_python import apache

def handler(req):
	objInst = MyObject(req)
	req.write(str(objInst))
	return apache.OK

class MyObject:
	def __init__(self, req):
		self.req = req

	def __str__(self):
		return "some string"

Jean Martin

-----Original Message-----
From: mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org]On Behalf Of Jean-Philippe
Barrette-LaPierre
Sent: mercredi, 25. août 2004 15:36
To: mod_python at modpython.org
Subject: [mod_python] objects as actions


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I wanted to use classes intead of function for actions in mod_python. The
only
thing it does is to display mymodule.myclass. I checked in the publisher
code
and I saw that if it's an object, it does:

result = str(object)

Why couldn't we do this instead:


class MyObject:
	def __init__(self, req):
		self.req = req

	def __str__(self):
		return "some string"


and in the publisher:

objInst = object(req)
result = str(objInst)

(if it's an object)

Maybe I'm using it incorrectly and it works with classes, but I didn't saw
any
way to do it
- --
Jean-Philippe Barrette-LaPierre
Maintener of curlpp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBLJWw4k/6r/h0g7kRAlPzAKDEWiQX5hI84DHo68UtLwMXM6qAGACg41qk
kdFuUQ3pbpM0oSZ4IAU7BQE=
=0ze9
-----END PGP SIGNATURE-----
_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python




More information about the Mod_python mailing list