Re: getFormatter

[email protected]
Newsgroups gmane.comp.web.zope.german
Message-ID <OFA4918267.B24E0DA2-ONC1257842.00276448-C1257842.0028028F@jci.com>
> Ich weiß jetzt immer noch nicht genau was du
erreichen möchtest aber

Sorry, ich dachte ich hätte es in meinem ursprünglichen
Post verständlich beschrieben, aber war wohl doch zu knapp.

Ok, in Zope 3 bzw. Grok mache ich folgendes:

tal:define="formatter python:request.locale.dates.getFormatter('dateTime')">

und kann dann später einen Datumswert wie folgt formatiert
ausgeben:

tal:content="python: formatter.format(meinDatumswert,
'dd-MMM-yyyy')"

Ich hatte gedacht, dass dies auch in Zope 2 ab 2.11(.1)
möglich sei. Nur kann ich dort nicht auf request.locale zugreifen. Carsten
hatte darauf hingewiesen, dass ich i18n(.locales) zuerst noch einbinden
muss, aber ich weiß nicht wie das geht.

Danke & Gruß,

Sascha

> in etwa so kannst du es testen:

>

> In deiner Klasse definierst du eine Methode

>

> class DeineKlasse:

> def test_dateformat(self):

> german=locales.getLocale('de', 'DE')

> f=german.dates.getFormatter('dateTime')

> return f.parse(s)

>

> Und im Template

>

> tal:content="python: context.test_dateformat(s)"

>

> Wobei s dein Datum String ist.

>

> Gruß

> Vlad



_______________________________________________
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.