RE: [Zope] string splitting in dtml

2000-12-06 Thread Spicklemire, Jerry

Mike said:

 I tried what you recommended and got the following error:

 Error Type: AttributeError
 Error Value: __getslice__

 The problem I think is that the variable is drawn from the database as
type
 date (Microsoft Access 2k) and somehow is cast into a date type.  Is there
a
 way to re-cast this variable as a string type?

You're right, it's not really a string, even though Zope is smart enough 
to render it into one when inserting it directly into HTML.

 I also tried the
 
 dtml-var "_.string.split(start_date, '/')[1]"
 
 solution but got the error:
 
 Error Type: TypeError
 Error Value: argument 1: expected read-only character buffer, instance
found

Now if only Zope were smart enough to tel us what it "really" is, 
so we could transform it! 

It looks like MS Access delivers dates as some proprietary object type.

However, in your query, you may be able to wrap the date field like so:

to_char(dateFieldName)

to convince MS Access to return a formatted string instead. 
Once you can see what the string looks like, the slicing bit 
should work.

Good Luck!
Jerry S.



___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] string splitting in dtml

2000-12-06 Thread Jim Washington

Just a thought:

Have you tried using "_.str(thedate)" to convert it into a string?  I am
not using Access, but since Zope can handle the Access date stuff
properly, it may be using something like _.str() internally.  It's what
I would try first.

-- Jim Washington

"Spicklemire, Jerry" wrote:
 
 Mike said:
 
  I tried what you recommended and got the following error:
 
  Error Type: AttributeError
  Error Value: __getslice__
 
  The problem I think is that the variable is drawn from the database as
 type
  date (Microsoft Access 2k) and somehow is cast into a date type.  Is there
 a
  way to re-cast this variable as a string type?
 
 You're right, it's not really a string, even though Zope is smart enough
 to render it into one when inserting it directly into HTML.
 
  I also tried the
 
  dtml-var "_.string.split(start_date, '/')[1]"
 
  solution but got the error:
 
  Error Type: TypeError
  Error Value: argument 1: expected read-only character buffer, instance
 found
 
 Now if only Zope were smart enough to tel us what it "really" is,
 so we could transform it!
 
 It looks like MS Access delivers dates as some proprietary object type.
 
 However, in your query, you may be able to wrap the date field like so:
 
 to_char(dateFieldName)
 
 to convince MS Access to return a formatted string instead.
 Once you can see what the string looks like, the slicing bit
 should work.

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] string splitting in dtml

2000-12-05 Thread Mike Kelland

I tried what you recommended and got the following error:

Error Type: AttributeError
Error Value: __getslice__

The problem I think is that the variable is drawn from the database as type
date (Microsoft Access 2k) and somehow is cast into a date type.  Is there a
way to re-cast this variable as a string type?  Or is there another reason
it's not working (I've tried it with my other varibles pulled from the
database in the same query and it's only the date types that are giving this
error, all other variables work fine)?

I also tried the

dtml-var "_.string.split(start_date, '/')[1]"

solution but got the error:

Error Type: TypeError
Error Value: argument 1: expected read-only character buffer, instance found

Thanks very much for everyone's help so far!
Mike Kelland
[EMAIL PROTECTED]

- Original Message -
From: "Spicklemire, Jerry" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, December 04, 2000 4:38 PM
Subject: [Zope] string splitting in dtml


 Mike asked:

  I have a date string (ie dd/mm/yy) which I'm drawing out of a database
  (ODBC connection to Access) with a Z SQL method and I need to use that
  data to set the initial condition of a set of 3 select items (ie day,
  month and year).  Is there a way to split this date (it'll come out
  looking like dd/mm/yy) to get the components of it

 You could use the Python "string slice" syntax, like so:

 dtml-let day_of_month="_['start_date'][:2]"
   month_of_year="_['start_date'][3:5]"
   year_of_century="_['start_date'][6:8]"
 The dtml-var day_of_month day,br
 of the dtml-var month_of_year month,br
 of the year 20dtml-var month_of_centurybr
 /dtml-let

 Later,
 Jerry S.

 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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  -  [EMAIL PROTECTED]
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] string splitting in dtml

2000-12-04 Thread Mike Kelland



I have a date string (ie dd/mm/yy) which I'm 
drawing out of a database (ODBC connection to Access) with a Z SQL method and I 
need to use that data to set the initial condition of a set of 3 select items 
(ie day, month and year). Is there a way to split this date (it'll come 
out looking like dd/mm/yy) to get the components of it so that I can do: 


select name="start_month"dtml-in 
"1,2,3,4,5,6,7,8,9,10,11,12"dtml-if"some_split_of_date_string_to_get_month(start_date)== 
_['sequence-item']"option value="dtml-var sequence-item" 
selecteddtml-var 
sequence-item/optiondtml-elseoption 
value="dtml-var sequence-item"dtml-var 
sequence-item/option/dtml-if/dtml-in/select

??


Thanks!

Mike Kelland
[EMAIL PROTECTED]



[Zope] string splitting in dtml

2000-12-04 Thread Spicklemire, Jerry

Mike asked:

 I have a date string (ie dd/mm/yy) which I'm drawing out of a database
 (ODBC connection to Access) with a Z SQL method and I need to use that
 data to set the initial condition of a set of 3 select items (ie day,
 month and year).  Is there a way to split this date (it'll come out
 looking like dd/mm/yy) to get the components of it 

You could use the Python "string slice" syntax, like so:

dtml-let day_of_month="_['start_date'][:2]"
  month_of_year="_['start_date'][3:5]"
  year_of_century="_['start_date'][6:8]"
The dtml-var day_of_month day,br
of the dtml-var month_of_year month,br
of the year 20dtml-var month_of_centurybr
/dtml-let

Later,
Jerry S.

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] string splitting in dtml

2000-12-04 Thread Andy McKay

dtml-var "_.string.split(start_date, '/')[1]"

will be the 2nd element of the start_date, in this case mm
--
  Andy McKay, Developer.
  ActiveState.


- Original Message -
From: "Mike Kelland" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 04, 2000 1:14 PM
Subject: [Zope] string splitting in dtml


I have a date string (ie dd/mm/yy) which I'm drawing out of a database (ODBC
connection to Access) with a Z SQL method and I need to use that data to set
the initial condition of a set of 3 select items (ie day, month and year).
Is there a way to split this date (it'll come out looking like dd/mm/yy) to
get the components of it so that I can do:

select name="start_month"
dtml-in "1,2,3,4,5,6,7,8,9,10,11,12"
dtml-if "some_split_of_date_string_to_get_month(start_date) ==
_['sequence-item']"
option value="dtml-var sequence-item" selecteddtml-var
sequence-item/option
dtml-else
option value="dtml-var sequence-item"dtml-var sequence-item/option
/dtml-if
/dtml-in
/select

??



Thanks!

Mike Kelland
[EMAIL PROTECTED]




___
Zope maillist  -  [EMAIL PROTECTED]
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 )