Re: [Zope] Populating a :list variable from the results of a ZSQL method

2000-11-10 Thread Phil Harris

tone,

How about (untested):

where 'dboptions' is the string pulled from the DB, and 'options' is the
list needed.



  


This would then give you take the string "['1','2','3']" and turn it into
the list [1,2,3].

hth

Phil

- Original Message -
From: "Tony McDonald" <[EMAIL PROTECTED]>
To: "Zope List" <[EMAIL PROTECTED]>
Sent: Friday, November 10, 2000 10:10 AM
Subject: [Zope] Populating a :list variable from the results of a ZSQL
method


> Hi all,
> Say I've got a form with this in it
>
> 
> number 1
> number 2
> number 3
> 
>
> When this is put into an SQL database, the field 'options' is this
(string)
>
> ['1', '2', '3']  or ['2', '3'] etc.
>
> When I get the data back from the database, 'options' comes back as a
> string, and  ...  gives errors (basically,
> it can't iterate over a string).
>
> I tried
> 
> and then tried iterating over new_options, but the variable didn't
exist...
>
> Has anyone got any solutions for this?
> TIA
> Tone
> --
> Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
> The Medical School, Newcastle University Tel: +44 191 222 5116
> A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope
>
> ___
> 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 )




Re: [Zope] Populating a :list variable from the results of a ZSQL method

2000-11-10 Thread Geir Bækholt


don't know about inside zope, but in plain python you could just do:

new_options = list(options)


perhaps an external method would cut it:

return list(inputstring)



--
Geir Bækholt
web-developer/designer
[EMAIL PROTECTED]
http://www.funcom.com

on Friday, November 10, 2000 Tony McDonald wrote :
TM> Hi all,
TM> Say I've got a form with this in it

TM> 
TM> number 1
TM> number 2
TM> number 3
TM> 

TM> When this is put into an SQL database, the field 'options' is this (string)

TM> ['1', '2', '3']  or ['2', '3'] etc.

TM> When I get the data back from the database, 'options' comes back as a 
TM> string, and  ...  gives errors (basically, 
TM> it can't iterate over a string).

TM> I tried
TM> 
TM> and then tried iterating over new_options, but the variable didn't exist...

TM> Has anyone got any solutions for this?
TM> TIA
TM> Tone
TM> --
TM> Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
TM> The Medical School, Newcastle University Tel: +44 191 222 5116
TM> A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope

TM> ___
TM> Zope maillist  -  [EMAIL PROTECTED]
TM> http://lists.zope.org/mailman/listinfo/zope
TM> **   No cross posts or HTML encoding!  **
TM> (Related lists - 
TM>  http://lists.zope.org/mailman/listinfo/zope-announce
TM>  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 )




Re: [Zope] Populating a :list variable from the results of a ZSQL method

2000-11-10 Thread Chris Withers

Tony McDonald wrote:
> 
> When this is put into an SQL database, the field 'options' is this (string)
> 
> ['1', '2', '3']  or ['2', '3'] etc.

So you're storing the sequence as a string of the type shown above...

...ow ;-)

Might be best to change your SQL Schema so your store one row per
option...

Nasty hack external method:

def eval_options(self):
return eval(self.REQUEST['options'])

then you can do:



...but be careful with that external method, it could be used to do all
sorts of bad things if it gets into the wrong hands.

cheers,

Chris

___
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] Populating a :list variable from the results of a ZSQL method

2000-11-10 Thread Tony McDonald

Hi all,
Say I've got a form with this in it


number 1
number 2
number 3


When this is put into an SQL database, the field 'options' is this (string)

['1', '2', '3']  or ['2', '3'] etc.

When I get the data back from the database, 'options' comes back as a 
string, and  ...  gives errors (basically, 
it can't iterate over a string).

I tried

and then tried iterating over new_options, but the variable didn't exist...

Has anyone got any solutions for this?
TIA
Tone
--
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 222 5116
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope

___
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 )