From: Kevin A. <al...@se...> - 2004-09-17 16:12:48
|
On Sep 17, 2004, at 8:15 AM, Gregory Pi=F1ero wrote: > Here's a longshot question. You know how you can write in python: > > a=3Draw_input("write text here") > > And basically when you run the program the user is prompted to enter > text, and you get the actual text the user entered. > > Is there any way to get raw_input from a text field in pyCard? Of > course I may already be getting this, but somehow by the time the > query gets to mySQL, it has gotten all mungled. > > I feel it is more a problem with the mySQL api if anything, but I was > curious if you guys had any ideas. I posted a question there which > has more details about the specific problem > = http://sourceforge.net/forum/forum.php?thread_id=3D1146165&forum_id=3D7046= 1 > > I would really appriciate it if anyone has any ideas at all, I've been > stuck on this problem for 3 days now. Maybe there's something > fundamental in python I'm doing wrong, but googling didn't turn up > anything useful. > > Thanks, > > -Greg > I don't know what you mean about raw input? Are you saying you want to=20= capture hidden control characters or you're having problems with=20 Unicode text or somehow you're quotes and apostrophes are getting=20 mangled? There isn't any special manipulations done to the text, the=20 text attribute is just an alias for the underlying wxPython GetValue=20 and SetValue methods which you'll see if you look at=20 PythonCard/components/textfield.py If you want to see exactly what the field contains just import pprint=20 and use pprint.pprint() to see what the text contains. For example,=20 running the minimal sample with the shell (-s on the command-line) you=20= can do: >>> import pprint >>> pprint.pprint(comp.field1.text) 'Hello PythonCard' >>> My guess is that you are having problems with SQL quoting rules and=20 should be using string formatting or interpolation as well as some=20 character escaping or normalization for problematic characters like=20 quotes. Perhaps Andy or some other person on the list that does more=20 SQL work than me will explain in more depth. Here's an example of building up a string from some vars. >>> s =3D "Hello %s is %d words." % ('World', 2) >>> s 'Hello World is 2 words.' >>> http://docs.python.org/lib/typesseq-strings.html ka |