Re: list oder string aus formular checkbox

Michael Graf <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <[email protected]>
Danke euch, isInstance() hat geholfen...


lg
michi

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Maik Derstappen, Derstappen IT
Gesendet: Montag, 28. Februar 2011 13:25
An: Deutschsprachige Zope-Benutzer-Liste
Betreff: [dzug-zope] Re: list oder string aus formular checkbox

Am 28.02.2011 13:12, schrieb Michael Graf:
>
> Hallo,
>
> irgendwo hab ich hier einen Denkfehler und dreh mich gerade dabei im
> Kreis:
>
> Und zwar ich habe ein einfaches Formular mit Checkboxen für eine Auswahl.
>
> Danach hab ich eine Überprüfung und sende die Validierten Daten
> danache ab.
>
> Und mein Problem dabei:
>
> Wenn ich mehrere Checkboxen auswähle kommen die Daten, wie sie sollen.
>
> [„Hallo“, „Welt“]
>
> Wenn ich aber nur eine Checkbox anwähle kommt nur ein String:
>
> Hallo
>
> Was anschliessend ein Problem is, da ich die einzelnen Items mittels
>
> python:', '.join(str(i) for i in options['programmes'])
>
> ausgebe!
>
> Ergebnis: H, a, l, l, o, W, e, l, t
>
>
Hallo Michael,

wenn nur ein Wert existiert, wird es als String übergeben sonst als Liste, daher dein Problem.
Überprüfe den Übergabewert auf einen String.
from types import StringType

if isinstance(programmes, StringType):
   progs = programmes
else:
   progs = ', '.join(str(i) for i in programmes)


und ja du möchtest das nicht im Template machen ;)

Gruß Maik

--
========================================================================

Derstappen    I T  Consulting   Tel:         +49 ( 341 )   600  13  0 31
Zope/E-Mail/Backup/Monitoring   Mobil:       +49 ( 178 )   861  2    833
M a i k   D e r s t a p p e n   Fax:         +49 ( 180 ) 5 021 121 90 56
H e r l o ß s o h n s t r  12   Email:  [email protected]
0 4 1 5 5       L e i p z i g   Internet:    http://www.derstappen-it.de

========================================================================



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope

________________________________

Diese Nachricht erhalten Sie von einem IMC Mitarbeiter.
Allfallige angehängte Dokumente sind vertraulich und nur für den/die Adressaten bestimmt. Sollten Sie nicht der beabsichtigte Adressat sein, ist jede Offenlegung, Weiterleitung oder sonstige Verwendung dieser Information nicht gestattet. In diesem Fall bitten wir, den Absender zu verstandigen und die Information zu vernichten. Für Übermittlungsfehler oder sonstige Irrtumer bei Übermittlung besteht keine Haftung.

This message is being transmitted by an IMC employee.
Any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the material. The sender does not accept liability for any errors or omissions as a result of the transmission.

Informationspflicht nach §14 UGB:

IMC Fachhochschule Krems GmbH
Piaristengasse 1, A-3500 Krems
Austria, Europe
ATU: 37552304
Firmenbuchnummer: 79297 p
Firmenbuchgericht: Landesgericht Krems an der Donau
DVR: 0798771
Fachgruppe Unternehmensberatung


_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.