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


Groups > comp.lang.python > #101603

Re: Data Entry

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Data Entry
Date Wed, 13 Jan 2016 12:21:25 +0100
Organization None
Lines 37
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>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de 93RvWkg40iFdCgj3l45edAW3mvQg/+MHrEquzILO1fwA==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.11; 'wed,': 0.15; '"%s",': 0.16; '%s,': 0.16; '2016': 0.16; 'attribute,': 0.16; 'ignores': 0.16; 'markup.': 0.16; 'multi-word': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Entry': 0.16; 'templating': 0.16; 'value:': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'skip:v 30': 0.20; 'do.': 0.22; 'space.': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'least': 0.27; 'correct': 0.28; '13,': 0.29; 'origin': 0.29; 'displayed': 0.33; 'quotes': 0.33; 'languages': 0.34; 'advice': 0.35; 'text': 0.35; 'url:dev': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'display': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'field': 0.60; 'save': 0.60; "you'll": 0.61; 'subject:Data': 0.66; 'bottle': 0.84; 'escaping': 0.84
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd9650.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:101603

Show key headers only | 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