November 30th, 2004, 01:22 AM
Session management with quixote.
Hoping for a general discussion type response to this thread.
I'm looking for information on handling sessions within the quixote framework.
For example: having constructed a form with various checkboxes and so forth, I am able to submit this form with a submitButton widget. Now say I want some more buttons/links that take me to another form page (with some generated tables retrieved via sql) with different funcionality (as opposed to a standard submit) - ie: "create new page/form and do this also" - (whereas a standard submit would just imply "create new page with this data available") - how would I do this?
From what I can tell, I would need sessions for this, so I'm looking for any helpful info on managing them in quixote.
Even if my assumption is incorrect, and I don't need sessions, I still have to implement session functionality as part of the project. So although alternative (and possibly superior) suggestions would be greatly appreciated, I'm still hoping for feedback on quixote sessions.
ps: say I have a standard html a href link tag, that I use to link to myform.ptl in the same folder - it would basically look like:
Now I need to be able to click on that link to go to that form AND send any relevant data along with it.
<a href="myform">Go to my form</a>
From what I understand in quixote, you can either render a form or process it, depending on whether its just been opened or is being submitted. I basically want to be able to "open a form for first time viewing" and be able to give it default data to populate its tables with.
From what I can tell this isn't as easy as it sounds.
I'm hoping I'm missing something neat and simple.
Last edited by Konstandinos; November 30th, 2004 at 02:02 AM.
Reason: Added comment on linking to ptl files.
December 2nd, 2004, 08:37 AM
For those of you who stumble accross this thread with the same question I had in the first post: I've found a solution.
Basically you use quixote's _q_lookup method to map dynamic URL's to objets (which you've defined in your quixote framework folder). The methods in these objects don't need to be exported - and as far as dynamic links go, all that happens is that _q_lookup(request, value) calls the object class, passes it the value (which is basically the end of the url string) and calls the respective method that you've defined to handle that particular value.
You can also implement checks to allow one to call different methods depending on the value's data, type, range etc.
Very useful indeed!
You're wondering what the use of all this is?
Well say you needed to link to a page called "EditStats" and based on the user that's logged in, say Bobby, you need to call "EditStats/Bobby". Now, Bobby is dynamic, therefore there is no way of having a static method called Bobby in your EditStats object (.py script). So you basically have a generic method (ie: dispDetails) which is called from the _q_lookup method, and the value Bobby is passed to it.
This would allow one to have a dynamic link:
This link is therefore generated on the fly, depending on the user, and when you click on it, quixote first maps "EditStats" to your EditStats object, and then looks for the "Bobby" method. Since this method doesn't exist, it then calls _q_lookup(request, value) which in turn calls the generic method dispDetails(value) that renders your page for editing Bobby's data.
user = getUser() #returns "Bobby"
<a href="EditStats/%s">Edit stats</a>
""" % (user)
I sure as hell think so.
Hope this helps peeps with their quixote.