[Zope] Getting a date into an object title - DON'T Disregard

Ronald L. Chichester complaw@hal-pc.org
Sat, 31 Mar 2001 14:18:50 -0600


Thanks Tim and Andy.

I think I figured out what the problem is.  Getting ZopeTime into the title isn't the
problem.  Getting the _user input_ that is meant to be a date into the title is the
problem.

Silly me, I was treating a user input from an HTML form for a date _as_ a date value,
when in reality it is only a string.  If I had tried myTitle = '%s' % contact_date
(instead of myTitle = '%d' % contact_date) everything would have worked.  What I need
to do is parse the string for the date and then create a true date property, or simply
rearrange the string as I need it (for the objects to sort correctly) and then just
feed that into the title.  Really simple once I figured out my conceptual mistake.

For those of you (Tim & Andy) who thought highly enough of me to think that I didn't
do something so foolish, Thank You.

I'll post the Python code for the technique (for posterity) so that someone else
looking for the same thing won't have to reinvent the wheel.

Ron

Tim Cook wrote:

> complaw@hal-pc.org wrote:
> >
> > Therapy or not, I spoke too soon.
> >
> > I did manage to get a time in as part of the title.  Unfortunately, the time
> > that I got was ZopeTime().
> >
> > What I want to get in is the time (really a date) set by the user.  This date is
> > taken in as input from the form page, it is then sent to a DTML Method that then
> > calls the Python script.  As I mentioned before, the parameter in question is
> > "contact_date".
> >
> > If I try to set myTitle = '%d' % contact_date then I get an error.
>
> Please Excuse the long post but maybe it will help someone else
> too.
>
> Ron,
> I didn't find where you said exactly what your error was. I am
> guessing it's a type mismatch. You are trying to assign a data to
> a string, or you're trying to concatenate a date and string. ???
>
> Since you want to sort by the date I would recommend the ISO()
> method.
> Below is a little DTML Method that will show you the results of
> most of the date formatting in Zope.
> HTH,
> Tim
>
> ------------------------------------------------------------
> <dtml-var standard_html_header>
> <h2>Display the date formats available in Zope</h2>
> <p>
> <dtml-let e="_.DateTime()">
> <ul>
> <li> strftime(%a) --> <dtml-var expr="e.strftime('%a')"></li>
> <li> strftime(%A) --> <dtml-var expr="e.strftime('%A')"></li>
> <li> strftime(%b) --> <dtml-var expr="e.strftime('%b')"></li>
> <li> strftime(%B) --> <dtml-var expr="e.strftime('%B')"></li>
> <li> strftime(%c) --> <dtml-var expr="e.strftime('%c')"></li>
> <li> strftime(%d) --> <dtml-var expr="e.strftime('%d')"></li>
> <li> strftime(%H) --> <dtml-var expr="e.strftime('%H')"></li>
> <li> strftime(%I) --> <dtml-var expr="e.strftime('%I')"></li>
> <li> strftime(%j) --> <dtml-var expr="e.strftime('%j')"></li>
> <li> strftime(%m) --> <dtml-var expr="e.strftime('%m')"></li>
> <li> strftime(%M) --> <dtml-var expr="e.strftime('%M')"></li>
> <li> strftime(%p) --> <dtml-var expr="e.strftime('%p')"></li>
> <li> strftime(%s) --> <dtml-var expr="e.strftime('%s')"></li>
> <li> strftime(%U) --> <dtml-var expr="e.strftime('%U')"></li>
> <li> strftime(%w) --> <dtml-var expr="e.strftime('%w')"></li>
> <li> strftime(%W) --> <dtml-var expr="e.strftime('%W')"></li>
> <li> strftime(%x) --> <dtml-var expr="e.strftime('%x')"></li>
> <li> strftime(%X) --> <dtml-var expr="e.strftime('%X')"></li>
> <li> strftime(%y) --> <dtml-var expr="e.strftime('%y')"></li>
> <li> strftime(%Y) --> <dtml-var expr="e.strftime('%Y')"></li>
> <li> strftime(%Z) --> <dtml-var expr="e.strftime('%Z')"></li>
> </ul>
> </p>
> <p>
> <ul>
> <li> dow() --> <dtml-var expr="e.dow()"></li>
> <li> aCommon() --> <dtml-var expr="e.aCommon()"></li>
> <li> h_12() --> <dtml-var expr="e.h_12()"></li>
> <li> HTML4() --> <dtml-var expr="e.HTML4()"></li>
> <li> dayOfYear() --> <dtml-var expr="e.dayOfYear()"></li>
> <li> AMPM() --> <dtml-var expr="e.AMPM()"></li>
> <li> Month() --> <dtml-var expr="e.Month()"></li>
> <li> mm() --> <dtml-var expr="e.mm()"></li>
> <li> ampm() --> <dtml-var expr="e.ampm()"></li>
> <li> hour() --> <dtml-var expr="e.hour()"></li>
> <li> aCommonZ() --> <dtml-var expr="e.aCommonZ()"></li>
> <li> pCommon() --> <dtml-var expr="e.pCommon()"></li>
> <li> minute() --> <dtml-var expr="e.minute()"></li>
> <li> day() --> <dtml-var expr="e.day()"></li>
> <li> Date() --> <dtml-var expr="e.Date()"></li>
> <li> Time() --> <dtml-var expr="e.Time()"></li>
> <li> TimeMinutes() --> <dtml-var expr="e.TimeMinutes()"></li>
> <li> yy() --> <dtml-var expr="e.yy()"></li>
> <li> dd() --> <dtml-var expr="e.dd()"></li>
> <li> rfc822() --> <dtml-var expr="e.rfc822()"></li>
> <li> fCommon() --> <dtml-var expr="e.fCommon()"></li>
> <li> fCommonZ() --> <dtml-var expr="e.fCommonZ()"></li>
> <li> timeTime() --> <dtml-var expr="e.timeTime()"> (this is a
> floating point number, not a string)</li>
> <li> parts() --> <dtml-var expr="e.parts()"> (this is a tuple,
> not a string)</li>
> <li> PreciseAMPM() --> <dtml-var expr="e.PreciseAMPM()"></li>
> <li> AMPMMinutes() --> <dtml-var expr="e.AMPMMinutes()"></li>
> <li> pDay() --> <dtml-var expr="e.pDay()"></li>
> <li> h_24() --> <dtml-var expr="e.h_24()"></li>
> <li> pCommonZ() --> <dtml-var expr="e.pCommonZ()"></li>
> <li> dow_1() --> <dtml-var expr="e.dow_1()">(integer)</li>
> <li> timezone() --> <dtml-var expr="e.timezone()"></li>
> <li> year() --> <dtml-var expr="e.year()"></li>
> <li> PreciseTime() --> <dtml-var expr="e.PreciseTime()"></li>
> <li> ISO() --> <dtml-var expr="e.ISO()"></li>
> <li> millis() --> <dtml-var expr="e.millis()"></li>
> <li> second() --> <dtml-var expr="e.second()"></li>
> <li> month() --> <dtml-var expr="e.month()">(integer)</li>
> <li> pMonth() --> <dtml-var expr="e.pMonth()"></li>
> <li> aMonth() --> <dtml-var expr="e.aMonth()"></li>
> <li> Day() --> <dtml-var expr="e.Day()"></li>
> <li> aDay() --> <dtml-var expr="e.aDay()"></li>
> </ul>
>
> </p>
>
> </dtml-let>
> <dtml-var standard_html_footer>
> --------------------------------------------------------------------
> --
> Tim Cook, President - FreePM,Inc.
> http://www.FreePM.com Office: (901) 884-4126
> ONLINE DEMO: http://www.freepm.org:8080/FreePM
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )