Hi, I have a problem with a python script... I want to know the month of a date. Therefor I use 'lastDate.strftime( '%m' )'. If I catch the date with 'lastDate = DateTime()' everything works fine, but if I define it manually ( 'lastDatee = 2002/01/18 21:34:18.4746 GMT+1' ), I am getting an attribute error: Error Type: AttributeError Error Value: strftime How can I turn the string into a date, so that strftime works again? MfG Steffen -- Es gibt keine perfekten Menschen, nur perfekte Absichten.
DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m') should work. In your example you just assign a *representation* of the date to a string instead of passing the representation to the constructor of the DateTime class. - aj ----- Original Message ----- From: "Steffen Hausmann" <Steffen@Hausmann-family.de> To: <zope@zope.org> Sent: Thursday, January 24, 2002 09:20 Subject: [Zope] turn string into date
Hi,
I have a problem with a python script...
I want to know the month of a date. Therefor I use 'lastDate.strftime( '%m' )'. If I catch the date with 'lastDate = DateTime()' everything works fine, but if I define it manually ( 'lastDatee = 2002/01/18 21:34:18.4746 GMT+1' ), I am getting an attribute error:
Error Type: AttributeError Error Value: strftime
How can I turn the string into a date, so that strftime works again?
MfG Steffen -- Es gibt keine perfekten Menschen, nur perfekte Absichten.
_______________________________________________ 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 )
Andreas Jung wrote:
DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m') should work. In your example you just assign a *representation* of the date to a string instead of passing the representation to the constructor of the DateTime class.
'DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m')' works fine, but it was only an example that I set 'lastDate' manualy in the script ( I thought it wouldn't make a difference, but it somehow does ). In reality 'lastDate' is passed to the script by a dtml-method which gets the date from an object's bobobase_modification_time. I tried 'DateTime( lastDate ).strftime( '%m' )' but I got a type error: Error Type: Invalid Date-Time String Error Value: If I change the script into 'return lastDate' it returns something like '2002/01/18 21:34:18.4746 GMT+1'. Thanks anyhow Steffen -- Es gibt keine perfekten Menschen, nur perfekte Absichten.
Steffen, You didn't mention what platform you're working on. If you're on MS-Windows anything, strftime should not work. Limitations to windows libraries keep python 2.1.* from offering strftime, which DateTime.py imports by default from time. If this is not the case with the python included in zope for win, please correct me. Troy Steffen Hausmann wrote:
Andreas Jung wrote:
DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m') should work. In your example you just assign a *representation* of the date to a string instead of passing the representation to the constructor of the DateTime class.
'DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m')' works fine, but it was only an example that I set 'lastDate' manualy in the script ( I thought it wouldn't make a difference, but it somehow does ).
In reality 'lastDate' is passed to the script by a dtml-method which gets the date from an object's bobobase_modification_time.
I tried 'DateTime( lastDate ).strftime( '%m' )' but I got a type error:
Error Type: Invalid Date-Time String Error Value:
If I change the script into 'return lastDate' it returns something like '2002/01/18 21:34:18.4746 GMT+1'.
Thanks anyhow Steffen
On Thu, Jan 24, 2002 at 07:18:00PM -0600, Troy Farrell wrote:
Steffen, You didn't mention what platform you're working on. If you're on MS-Windows anything, strftime should not work. Limitations to windows libraries keep python 2.1.* from offering strftime, which DateTime.py imports by default from time. If this is not the case with the python included in zope for win, please correct me.
I'm currently working on SuSE 7.0 with Zope 2.4.3 stable. I took a look at 'DateTime.py' that comes with Zope. And I've found an entry that defines the strftime funktion ( 'def strftime(self, format):' ). Thanks anyhow Steffen -- Es gibt keine perfekten Menschen, nur perfekte Absichten.
While I recommend Zope to others, I was offen questioned this kind of question: "How can I protect my softwares in Zope"? As I know, once I got a Data.fs, I can access this Data.fs by creating an emergency admin account. Is there any way to absolutely lock (protect from source DTMLs, ZClasses be viewed) 1. the Data.fs 2. ZClass-based Products 3. external methods 4. and the Instances Thanks for any suggestions. Iap, Singuan
Mmm, I'm not sure, but, if people have access to your data.fs file... then there is a security problem of your filesystem, since if people can go without problem on your filesystem, they can do whatever they want... Tom. ----- Original Message ----- From: <iap@y2fun.com> To: <zope@zope.org> Sent: Friday, January 25, 2002 3:05 PM Subject: [Zope] How can I protect my softwares in Zope
While I recommend Zope to others, I was offen questioned this kind of question: "How can I protect my softwares in Zope"?
As I know, once I got a Data.fs, I can access this Data.fs by creating an emergency admin account.
Is there any way to absolutely lock (protect from source DTMLs, ZClasses be viewed) 1. the Data.fs 2. ZClass-based Products 3. external methods 4. and the Instances
Thanks for any suggestions.
Iap, Singuan
_______________________________________________ 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 )
DateTime('2002/01/18 21:34:18.4746 GMT+1' ).strftime('%m') should work. In your example you just assign a *representation* of the date to a string instead of passing the representation to the constructor of the DateTime class. - aj ----- Original Message ----- From: "Steffen Hausmann" <Steffen@Hausmann-family.de> To: <zope@zope.org> Sent: Thursday, January 24, 2002 09:20 Subject: [Zope] turn string into date
Hi,
I have a problem with a python script...
I want to know the month of a date. Therefor I use 'lastDate.strftime( '%m' )'. If I catch the date with 'lastDate = DateTime()' everything works fine, but if I define it manually ( 'lastDatee = 2002/01/18 21:34:18.4746 GMT+1' ), I am getting an attribute error:
Error Type: AttributeError Error Value: strftime
How can I turn the string into a date, so that strftime works again?
MfG Steffen -- Es gibt keine perfekten Menschen, nur perfekte Absichten.
_______________________________________________ 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 )
participants (5)
-
Andreas Jung -
iap@y2fun.com -
Steffen Hausmann -
Tom Deprez -
Troy Farrell