Re: [Zope] Getting a date into an object title - DON'T Disregard
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. However, if I try to set myTitle = '%d' % report_title then I don't get an error. The report_title parameter was set in the DTML Method that was called by the HTML form. that code is <dtml-let report_title="ZopeTime()"> Unfortunately, if I set <dtml-let report_title=contact_date> I get an error. Note, the </dtml-let> is AFTER the call to the python script. Is there something I'm missing? TIA, Ron
Is there something therapeutic/magical about this list?
Of course, you didnt know ;)
BTW I normally set the id equal to the time in secs... which gives a horrible url but has *loads* of other advantages. -- Andy McKay.
----- Original Message ----- From: <complaw@hal-pc.org> To: <complaw@hal-pc.org>; <zope@zope.org> Sent: Friday, March 30, 2001 9:54 AM Subject: Re: [Zope] Getting a date into an object title - DISREGARD
Why is it that within 5 minutes after posting a notice on this list that I figure out a solution to the problem?
Is there something therapeutic/magical about this list?
Ron
I want to put a date value into a DTML Document title so that when the DTML Documents are sorted by their title, they will automatically be sorted by date. (Incidentally, the title also has some other non-date information.)
I've tried various schemes and they don't work. I'm using the Zope book template for creating the DTML Documents (which are loaded by the users who don't have manage access). This means that I have a form to gether information (including the contact date, which is transmitted from the form as "contact_date"). The form calls an DTML method that calls a Python script which creates the DTML Document.
Any hints, either in DTML or for the Python script, would be most appreciated.
Thanks,
Ron
_______________________________________________ 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 )
_______________________________________________ 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 )
_______________________________________________ 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 )
_______________________________________________ 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 )
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
Tim This is wonderful! Thank you so much.. I wish all Zope docs had such straightahead useful & comprehensive examples. best wishes - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] ----- Original Message ----- From: Tim Cook <tim@freepm.org> ...snip...
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>
..etc..
Jason Cunliffe wrote:
Tim
This is wonderful! Thank you so much.. I wish all Zope docs had such straightahead useful & comprehensive examples.
Thanks Jason. Realize though that I got the information from the Zope API in the Help system. It's all there, you just sometimes have to look harder. <s> -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
From: Tim Cook <tim@freepm.org>
Jason Cunliffe wrote:
Tim
This is wonderful! Thank you so much.. I wish all Zope docs had such straightahead useful & comprehensive examples.
Thanks Jason. Realize though that I got the information from the Zope API in the Help system. It's all there, you just sometimes have to look harder. <s>
Indeed :-) In fact your post promted me to dive into the ZopeBook appendix. Right now I am creating some DTML in the same style as your examples for general methods etc. One of the most frustrating things to me is that without certani kinds of explicit newbie examples, a lot of documentation evades me. I can see a lot of information is there, but how to actually use it. Often [as soon as you know how :-)], it turns out be incredibly simple. for example I look at the API/Docs but {Doh!} I did not realize how that whole list of variations for ZopeTime could be accessed like that. Another example is one I am going through right now: class PropertyManager 'A Property Manager object has a collection of typed attributes called properties. Properties can be managed through the web or via DTML.' Until I started reading Dieter's famous Chapter 3, I could not really bridge the words 'property manager' with the overview/concept some tangible, something DTML/Python. Who/Where is this property manager I keept wondering..? Most of the API prose has for me this mysterious look but can't quite touch quality. Once one does have a consistent real-world example of use, then a lot of things fall into place. For example it took me a while to realize that when I read <dtml-var expr = "someZopeMagic"> That expr was precisely what UI was meant to type and only that. At first I thought it meant 'some expr goes here'!@#$ phew ;-) The use of fonts or lack of good delineation really confused me alot and still does.. I am praying that New Riders do a nice job by making correct dsitinctions between excample, literal, options etc for Zope program formatting. I am a visual artist on my way to becoming some kind of a happy programmer, so perhaps many can't appreciate what I am making such a big deal about. In reality it is simply that have a whole lot of information spelled out and presented in a consistent readable manner one can compare and learn very raidly, which of course leads to creative experiments.. For me, it is often not that Zope lacks Documentation, but simply I do not know yet how to use well what there is. A nice resource I have been going over is AlexR's sorted HowTos: http://www.zope.org/Members/AlexR/all_howtos_date?pp=1 cheers - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
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 )
"Ronald L. Chichester" wrote:
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
A couple of very applicable HOWTOs: http://www.zope.org/Members/Zen/howto/FormVariableTypes http://www.zope.org/Members/Duncan/RecogniseTypes -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (901) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
participants (4)
-
complaw@hal-pc.org -
Jason Cunliffe -
Ronald L. Chichester -
Tim Cook