Re: How to implement a dropdownlist in CherryPy where selected item is returned as argument appended to current URL?

Walter Jaisli <[email protected]> Wed, 15 May 2019 10:32:46 +0200
Newsgroups gmane.comp.python.cherrypy
Message-ID <CAKM90wNyxFNC_WpBu3JX3_dfuOH75XhqOb7K8BXq60kWU_H6pg@mail.gmail.com>
--00000000000025a4b30588e8ffc2
Content-Type: text/plain; charset="UTF-8"

what you can do ist something like (as content of a Python Script) :

import cherrypy

class dropDown(object):
    @cherrypy.expose
    def number(self, selected = ''):
        view = ''
        if selected  != '':
           view = 'you selected '+selected
        html = '<html><body>'

        html += '<form action = "/number" id="myForm">'
        html += '<select name="selected"
onChange=document.getElementById("myForm").submit()>'
        html += '<option value="1-Test">1-Test</option>'
        html += '<option value="2-Debug">2-Debug</option>'
        html += '<option value="...">...</option>'
        html += '<option value="...">...</option>'
        html  += '<select>'
        html += '<form>'
        html += view

        html += '</body></html>'
        return html

cherrypy.quickstart(dropDown())

you find your dropdown list with:  localhost:8080/number

but as Tim Roberts says:  it works only with Javascript activated.
Walter Jaisli

Am Mi., 15. Mai 2019 um 00:42 Uhr schrieb Tim Roberts <[email protected]>:

> Jibun no Kage wrote:
> >
> > As I am sure many have gathered, I am working under some unique
> > requirements.  Straight HTML would be without use of any optional
> > scripting language, i.e. that will likely be disabled.  Java script as
> > one example is restricted and even prohibited in some secured
> > environments.  In secured micro-controller environments for example,
> > there are quite a number of limits and restrictions unique to the
> > environment at hand.  This is also typical of Internet-of-Things
> > implementations for example.
>
> IoT devices run a web SERVER, not a web BROWSER.  A web browser is a UI
> concept, and IoT devices don't have a UI.  Javascript runs in the web
> browser, not on the server.
>
>
> > So assumption that Java is available, i.e. enabled is not a given. ...
>
> JavaSCRIPT.  Please, those two are very, very, very different languages
> used for very different purposes.  The world was done a huge misservice
> when Netscape decided to rename ECMAScript to Javascript in order to
> cash in on the "cool word of the day".  You MUST get your terminology
> straight, because I think that's were some of your confusion arises.
> Your IoT device can send Javascript code in the HTML pages it sends out,
> knowing that it will be read and executed by a competent web browser on
> a user's laptop somewhere.
>
>
> > Moreover, the design goals I am working with is to not use additional
> > scripting support, and Java is explicitly prohibited.
>
> Java or Javascript?  There was a time that Java was proposed as a
> browser-extension language, just like Microsoft's ActiveX controls.
> That time is gone.  I can believe that Java is prohibited.  However,
> Javascript support is ubiquitous.  EVERY non-toy browser has it, and it
> is secure.  I do not believe any serious web-based project today would
> prohibit Javascript.  It doesn't make sense.
>
>
> > This of course limits the flexibility of the design significantly.
>
> Yes.  For example, you cannot implement an "automatic" dropdown list
> without Javascript.  It is impossible.  Forms can only be submitting by
> having the user click a "submit" button.
>
>
> > I am trying a few things using the change of focus and hover events,
> > time to get creative.
>
> Change of focus and hover events execute Javascript code.   If you are
> allowed to handle events, then you are allowed to use Javascript.
>
> --
> Tim Roberts, [email protected]
> Providenza & Boekelheide, Inc.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> Visit this group at https://groups.google.com/group/cherrypy-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cherrypy-users/b8b7661c-4e82-2e42-b2ea-319e3c104ad4%40probo.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAKM90wNyxFNC_WpBu3JX3_dfuOH75XhqOb7K8BXq60kWU_H6pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--00000000000025a4b30588e8ffc2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div>what you can do ist something like (=
as content of a Python Script) :</div><div><br></div><div>import cherrypy<b=
r><br>class dropDown(object): <br>=C2=A0=C2=A0=C2=A0 @cherrypy.expose=C2=A0=
=C2=A0 <br>=C2=A0=C2=A0=C2=A0 def number(self, selected =3D &#39;&#39;):<br=
>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 view =3D &#39;&#39;<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if selected=C2=A0 !=3D &#39;&#39;:<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 view =3D &#39;=
you selected &#39;+selected <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
html =3D &#39;&lt;html&gt;&lt;body&gt;&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &#=
39;&lt;form action =3D &quot;/number&quot; id=3D&quot;myForm&quot;&gt;&#39;=
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &#39;&lt;select na=
me=3D&quot;selected&quot; onChange=3Ddocument.getElementById(&quot;myForm&q=
uot;).submit()&gt;&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html =
+=3D &#39;&lt;option value=3D&quot;1-Test&quot;&gt;1-Test&lt;/option&gt;&#3=
9;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &#39;&lt;option =
value=3D&quot;2-Debug&quot;&gt;2-Debug&lt;/option&gt;&#39;<br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &#39;&lt;option value=3D&quot;...&=
quot;&gt;...&lt;/option&gt;&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 html +=3D &#39;&lt;option value=3D&quot;...&quot;&gt;...&lt;/option&gt;=
&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html=C2=A0 +=3D &#39;&l=
t;select&gt;&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &=
#39;&lt;form&gt;&#39;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=
=3D view<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 html +=3D &#39;&lt;/body&gt;&lt;/html&gt;&#39;<=
br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return html<br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>cherrypy.quickstart(dropDown())=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br><br></div><div>you find your dropdown=
 list with:=C2=A0 localhost:8080/number</div><div><br></div><div>but as Tim=
 Roberts says:=C2=A0 it works only with Javascript activated.</div><div>Wal=
ter Jaisli<br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"=
ltr" class=3D"gmail_attr">Am Mi., 15. Mai 2019 um 00:42=C2=A0Uhr schrieb Ti=
m Roberts &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt;:<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left:1px solid rgb(204,204,204);padding-left:1ex">Jibun no Kage wrote=
:<br>
&gt;<br>
&gt; As I am sure many have gathered, I am working under some unique <br>
&gt; requirements.=C2=A0 Straight HTML would be without use of any optional=
 <br>
&gt; scripting language, i.e. that will likely be disabled.=C2=A0 Java scri=
pt as <br>
&gt; one example is restricted and even prohibited in some secured <br>
&gt; environments.=C2=A0 In secured micro-controller environments for examp=
le, <br>
&gt; there are quite a number of limits and restrictions unique to the <br>
&gt; environment at hand.=C2=A0 This is also typical of Internet-of-Things =
<br>
&gt; implementations for example.<br>
<br>
IoT devices run a web SERVER, not a web BROWSER.=C2=A0 A web browser is a U=
I <br>
concept, and IoT devices don&#39;t have a UI.=C2=A0 Javascript runs in the =
web <br>
browser, not on the server.<br>
<br>
<br>
&gt; So assumption that Java is available, i.e. enabled is not a given. ...=
 <br>
<br>
JavaSCRIPT.=C2=A0 Please, those two are very, very, very different language=
s <br>
used for very different purposes.=C2=A0 The world was done a huge misservic=
e <br>
when Netscape decided to rename ECMAScript to Javascript in order to <br>
cash in on the &quot;cool word of the day&quot;.=C2=A0 You MUST get your te=
rminology <br>
straight, because I think that&#39;s were some of your confusion arises.=C2=
=A0 <br>
Your IoT device can send Javascript code in the HTML pages it sends out, <b=
r>
knowing that it will be read and executed by a competent web browser on <br=
>
a user&#39;s laptop somewhere.<br>
<br>
<br>
&gt; Moreover, the design goals I am working with is to not use additional =
<br>
&gt; scripting support, and Java is explicitly prohibited.<br>
<br>
Java or Javascript?=C2=A0 There was a time that Java was proposed as a <br>
browser-extension language, just like Microsoft&#39;s ActiveX controls.=C2=
=A0 <br>
That time is gone.=C2=A0 I can believe that Java is prohibited.=C2=A0 Howev=
er, <br>
Javascript support is ubiquitous.=C2=A0 EVERY non-toy browser has it, and i=
t <br>
is secure.=C2=A0 I do not believe any serious web-based project today would=
 <br>
prohibit Javascript.=C2=A0 It doesn&#39;t make sense.<br>
<br>
<br>
&gt; This of course limits the flexibility of the design significantly. <br=
>
<br>
Yes.=C2=A0 For example, you cannot implement an &quot;automatic&quot; dropd=
own list <br>
without Javascript.=C2=A0 It is impossible.=C2=A0 Forms can only be submitt=
ing by <br>
having the user click a &quot;submit&quot; button.<br>
<br>
<br>
&gt; I am trying a few things using the change of focus and hover events, <=
br>
&gt; time to get creative.<br>
<br>
Change of focus and hover events execute Javascript code.=C2=A0=C2=A0 If yo=
u are <br>
allowed to handle events, then you are allowed to use Javascript.<br>
<br>
-- <br>
Tim Roberts, <a href=3D"mailto:[email protected]" target=3D"_blank">timr@probo=
.com</a><br>
Providenza &amp; Boekelheide, Inc.<br>
<br>
<br>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;cherrypy-users&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:cherrypy-users%2Bunsubscribe-/[email protected]" ta=
rget=3D"_blank">cherrypy-users+unsubscribe-/[email protected]</a>.<br>
To post to this group, send email to <a href=3D"mailto:cherrypy-users@googl=
egroups.com" target=3D"_blank">cherrypy-users-/[email protected]</a>.<br>
Visit this group at <a href=3D"https://groups.google.com/group/cherrypy-use=
rs" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com/group/ch=
errypy-users</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/cherrypy-users/b8b7661c-4e82-2e42-b2ea-319e3c104ad4%40probo.com"=
 rel=3D"noreferrer" target=3D"_blank">https://groups.google.com/d/msgid/che=
rrypy-users/b8b7661c-4e82-2e42-b2ea-319e3c104ad4%40probo.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"noreferrer" target=3D"_blank">https://groups.google.com/d/optout</a>.<b=
r>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;cherrypy-users&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:cherrypy-users+unsubscribe-/[email protected]">cher=
rypy-users+unsubscribe-/[email protected]</a>.<br />
To post to this group, send email to <a href=3D"mailto:cherrypy-users@googl=
egroups.com">cherrypy-users-/[email protected]</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/group/cherrypy-use=
rs">https://groups.google.com/group/cherrypy-users</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/cherrypy-users/CAKM90wNyxFNC_WpBu3JX3_dfuOH75XhqOb7K8BXq60kWU_H6=
pg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.=
google.com/d/msgid/cherrypy-users/CAKM90wNyxFNC_WpBu3JX3_dfuOH75XhqOb7K8BXq=
60kWU_H6pg%40mail.gmail.com</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

--00000000000025a4b30588e8ffc2--