On 28/07/11 12:26, Mike Orr wrote:
On Wed, Jul 27, 2011 at 11:15 PM, Krishnakant Mane<[email protected]> wrote:
Hello all.
I have a requirement where a pylons action controller gets data fromm
request.params["companyname"] and put it into an xml file at the server
side.
it has many other fields but here I am just making things simple.
Now my problem is that when user enters special characters such as&, for
example "mark& spencer " then the code fails.
Obviously I think somewhere we need to convert this into cdata. Is there
some way in which I instruct the request to send the values in cdata?
Where and how does it fail?
CDATA is not a way to protect against markup crashes. It's just a bulk
quoting mechanism to avoid having to quote individual& < > in a chunk
of text. But Pylons should automatically quote all the data values in
your outgoing template, so you don't need CDATA. Unless perhaps you're
trying to embed Javascript in an HTML file and the quoting rules are
getting too complex; but the answer there is to put the Javascript in
a separate file.
If you send a form to the user and they enter "mark& spencer" in a
text field, it should come back to you as a properly-formatted POST
document containing "mark& spencer". WebOb will automatically
decode that to u"mark& spencer" for you. You put that in a template
variable (c.name => ${name}), and Pylons/Mako's default filter
should convert that to "mark& spencer" in the output XML. If
that's not working, we need to know where exactly it's breaking down,
or what you're doing differently than this.
A very unlikely possibility is that the browser is returning
misformatted POST input, which is choking WebOb. But I have never seen
a browser do that.
Yes I have one thing different.
The return is in a json object.
I have @jsonify at the top of my action.
So the organisation name gets processed that way.
Problem also seems to be that when an ajax function is called to send
the value back for processing, it must be doing some thing wrong.
Let me explain the exact situation.
In accounting, we have books maintained for every financial year.
So first I choose an organisation name fromm the dropdown and an ajax
request is sent to retrive its financial year.
So when I try doing this, I see that the entire application crashes.
Secondly I also have a strong doubt that when organisation is deployed
in the first place, the data might not be encoded properly so when we
retrive back the data its not in proper format.
so when I create a new organisation with name as Mark & spencer, I
wonder if its going in the right way inside request.params.
I printed it to the terminal and came right.
But now when I have it in the dropdown it means c.name worked right.
The problem only happens when I send that back for processing (meaning
getting the financial year which was earlier saved for selected
organisation).
Now the controller retrives the exact financial year for the requested
organisation.
But the value of the requested organisation seems to get currupt
somewhere and so the retrival mechanism fails.
Happy hacking.
Krishnakant.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.