Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101603

Re: Data Entry

From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Data Entry
Date 2016-01-13 12:21 +0100
Organization None
Message-ID <mailman.97.1452684100.13488.python-list@python.org> (permalink)
References <6ea58259-05f8-40b5-8c85-46a69668c8e6@googlegroups.com> <CAPTjJmqjLf=1ZguFgxxxRQwf2jYXoQerS=avd5z_ENEOUM_XEw@mail.gmail.com>

Show all headers | View raw


Chris Angelico wrote:

> On Wed, Jan 13, 2016 at 12:52 PM,  <tdsperth@gmail.com> wrote:
>> If i change the value from origin to origin energy and save - the value
>> updated to the database is correct but when the page is re displayed it
>> only shows origin in the text field - as if it ignores everything after
>> the space.
>>
>> How do I make it display the full name.
>>
> 
> To set a multi-word value as an HTML attribute, you'll need to put
> quotes around it. You might be able to get away with using %r instead
> of %s, or even just "%s", 

That is bad advice that "works" until there is a value containing 
quotes or other markup.

> but proper escaping would be the best way.

OP, that's what you should do. Either pick one of the many templating 
languages -- a simple one is

http://bottlepy.org/docs/dev/stpl.html

>>> from bottle import SimpleTemplate
>>> SimpleTemplate('... value="{{supplier}}">').render(
... supplier="<foo> 'bar' \"baz\"")
'... value="&lt;foo&gt; &#039;bar&#039; &quot;baz&quot;">'

-- or at least manually apply html.escape() to the value:

>>> import html
>>> '... value="%s">' % html.escape("<foo> 'bar' \"baz\"")
'... value="&lt;foo&gt; &#x27;bar&#x27; &quot;baz&quot;">'

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Data Entry tdsperth@gmail.com - 2016-01-12 17:52 -0800
  Re: Data Entry Chris Angelico <rosuav@gmail.com> - 2016-01-13 13:01 +1100
  Re: Data Entry tdsperth@gmail.com - 2016-01-12 18:58 -0800
  Re: Data Entry Peter Otten <__peter__@web.de> - 2016-01-13 12:21 +0100
  Re: Data Entry Chris Angelico <rosuav@gmail.com> - 2016-01-13 22:29 +1100

csiph-web