[mod_python] calla function from form and via link

Mike Verdone mike_verdone at shaw.ca
Tue Jan 21 20:56:29 EST 2003


On January 21, 2003 03:41 am, sandor.kopanyi at mailbox.hu wrote:
> I have a function which fetches some things from a database; it has
> 2 parameters: req and an id. The req is used to extract username and
> password for the database connection, the second is info needed for
> fetch.
>
> My problem: I would like to use the same function, with the same
> purpose, but in this not from a FORM. but from a dynamically generated
> web-page
> (http://...module.py/function?id=somethingdynamicallygenerated).
> But in this case I - obviously - miss the req, which is "given" to me
> only
> when calling a function from a FORM.

I'm not sure if I know what you mean., but req should always be given to you, 
even when you are accessing a page with a plain old GET request. So:

http://.../function?id=blah

should give you the request object, and same with

http://.../function

Basically, just put the whole link to the function in an <A> tag, and it will 
work same as a form submission.

I'm not sure how the database password got into the req in the first place. Is 
it supplied by the user at some point, or is it the same for every user? If 
the user supplies it on some other page, you'll have to use some session 
handling (google for "python service objects" for some info). If it's always 
the same, hard code it into a module somewhere.

Do I understand correctly?

Mike.




More information about the Mod_python mailing list