REQUEST = container.REQUEST 
Author Message
 REQUEST = container.REQUEST

If i inport a var from a dtml form to python the var coms with ' '

THE peace of code  

REQUEST = container.REQUEST
Bdag = REQUEST['Bdag']

REQUEST = container.REQUEST
Bmaand = REQUEST['Bmaand']

REQUEST = container.REQUEST
Bjaar = REQUEST['Bjaar']

bdate = DateTime(Bjaar,Bmaand,Bdag,0,0,0)

THE error

Error Type: DateTimeError
Error Value: Invalid date: ('2002', '1', '1', 0, 0, 0)

so how i get the ' ' of the var

thx PaTriX




Tue, 25 Oct 2005 16:54:51 GMT  
 REQUEST = container.REQUEST

    patrix> If i inport a var from a dtml form to python the var coms
    patrix> with ' ' THE peace of code

    patrix> REQUEST = container.REQUEST Bdag = REQUEST['Bdag']
    patrix> REQUEST = container.REQUEST Bmaand = REQUEST['Bmaand']
    patrix> REQUEST = container.REQUEST Bjaar = REQUEST['Bjaar']
    patrix> bdate = DateTime(Bjaar,Bmaand,Bdag,0,0,0)

    patrix> THE error
    patrix> Error Type: DateTimeError Error Value: Invalid date:
    patrix> ('2002', '1', '1', 0, 0, 0)
    patrix> so how i get the ' ' of the var

Maybe my eyes are just failing me, but in the exception

    Error Type: DateTimeError Error Value: Invalid date:
    ('2002', '1', '1', 0, 0, 0)

I don't see any spaces, so this may not be your problem.  However, you
are mixing strings and integers -- that looks suspicious.

Try this:

  bdate = DateTime('%04d-%02d-%02d' % (int(year), int(month), int(day)))

This will create a formatted string like '2002-01-01' which date time
will be happy to process

Also, you do not need to set the request multiple times, the following
will do

    REQUEST = container.REQUEST  # or is context.REQUEST better?
    year  = REQUEST['Bdag']
    month = REQUEST['Bmaand']
    day   = REQUEST['Bjaar']
    bdate = DateTime('%04d-%02d-%02d' % (int(year), int(month), int(day)))

JDH



Tue, 25 Oct 2005 23:22:23 GMT  
 REQUEST = container.REQUEST

Quote:

>If i inport a var from a dtml form to python the var coms with ' '

>THE peace of code  

>REQUEST = container.REQUEST
>Bdag = REQUEST['Bdag']

>REQUEST = container.REQUEST
>Bmaand = REQUEST['Bmaand']

>REQUEST = container.REQUEST
>Bjaar = REQUEST['Bjaar']

>bdate = DateTime(Bjaar,Bmaand,Bdag,0,0,0)

>THE error

>Error Type: DateTimeError
>Error Value: Invalid date: ('2002', '1', '1', 0, 0, 0)

>so how i get the ' ' of the var

I'm surprised at that particular error, instead of "__init__() takes at
most 2 arguments"..

DateTime takes a time tuple as a parameter, which has 9 integer elements,
not 6.  You can convert the strings to ints using the "int()" operator.
Note that you need TWO sets of parens: one for the function, one for the
tuple:

bdate = DateTime((int(Bjaar),int(Bmaand),int(Bdag),0,0,0,0,0,0))
--

  Providenza & Boekelheide, Inc.



Wed, 26 Oct 2005 13:15:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Request: module that converts iis Request module to Dict like object

2. Difference Container / Packeting Container ?

3. Why Smalltalk Updates and a request

4. Some feature requests for D6

5. GUI implementation critique requested

6. Statusbar critique requested

7. Chwastyk's request for Mathematica help

8. reply to a request for statistical workspaces

9. Feature requests/wish list

10. Help requested for APL on PC

11. implementation summary requested

12. External Function Request

 

 
Powered by phpBB® Forum Software