#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Cape Town, South Africa
    Posts
    131
    Rep Power
    12

    Question Session management with quixote.


    Hey peeps

    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.

    Cheers,
    Kosta

    (edited)

    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:

    Code:
    <a href="myform">Go to my form</a>
    Now I need to be able to click on that link to go to that form AND send any relevant data along with it.

    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Cape Town, South Africa
    Posts
    131
    Rep Power
    12

    Solution found.


    Howdy,

    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:

    Code:
    user = getUser() #returns "Bobby"
    """
    ...
    <a href="EditStats/%s">Edit stats</a>
    ...
    """ % (user)
    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.

    Nifty?

    I sure as hell think so.

    Hope this helps peeps with their quixote.

    Cheers,
    K

IMN logo majestic logo threadwatch logo seochat tools logo