Google Groups Home
Help | Sign in
adjust_value and cherrypy.request.input_values confusion
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
jthibeaux  
View profile
 More options Jul 24, 1:26 pm
From: jthibeaux <jthibe...@gmail.com>
Date: Thu, 24 Jul 2008 10:26:53 -0700 (PDT)
Local: Thurs, Jul 24 2008 1:26 pm
Subject: adjust_value and cherrypy.request.input_values confusion
While I have managed to get what I want to do to work, I am not
particularly satisfied with the solution cause I am convinced that
this isn't an elegant way to go about things.  That is, it feels like
a hack.

The simple problem is I have a query form that is re-displayed with
the results of the query.  I would like to retain the values the user
submitted in the form; however, one of the fields, if it is empty, I
want to change the value to a hint string like "type in X here."

On first glance, I thought I could use the adjust_value method on the
form to check if the current value for that field is empty, and, if
so, set "type in X here"; however, this adjustment promptly gets
ignored during page rendering.

The reason why seems to be in the code for InputWidget:

    def adjust_value(self, value, **params):
        if hasattr(request, "input_values") and self.is_validated:
            input_submitted = True
            iv = retrieve_value_by_path(request.input_values,
self.name_path)

This seems to be subverting whatever value assignment I make for the
form to use cherrypy.request.input_values instead.

Now, my workaround is simply to set
cherrypy.request.input_values['field'] = "type in X here" when
adjusting the values.  Is there no other way to force a value
adjustment that will also override user input?

Jeremy


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google