Re: Two question

Jacob Smullyan <[email protected]> Wed, 21 Sep 2005 11:16:28 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Wed, Sep 21, 2005 at 09:38:06PM +0700, Rachman Chavik wrote:

I'm cc-ing the list.

> 1. Is there a way to build SET programmatically.
>    Instead of writing SET(100,200,300) and so on, can we write
>     myset=SET()
>     myset.append(100)
>     myset.append(200)
>     myset.append(300)
> 
>     Then later, I'll want use myset in:
>      getSome(IN(FIELD('CUSTOMER_ID', myset)).
> 
>     Or am I going about this in a wrong way?

Python provides a way:

   # generate this however you want
   mylist=[100, 200, 300]  
   getSome(IN(FIELD('CUSTOMER_ID'), SET(*mylist)))
> 
> 2. Is it possible to create a class, but instead of using table_name, it
> uses an SQL statement?
> 
>     eg:
>     class MyView(PyDO):
>        connectionAlias = 'conn'
>        table = "select foo.id, foo.name, bar.amount from foo, bar where
> foo.id = bar.id"
>        fields=('id', 'name', 'amount')


This isn't really supported at present.  I believe that trying to use
a subselect would break, but you can try it.  If your database
supports views, you can use them.

Cheers,

js

-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDMXlMuqamFyFXXLIRAgPwAJ9JfBZ8ccnUTlHxmUEmIpGsQAms9gCePWHv
+dz11T95cOyJ/wb9q0yp0z0=
=26VE
-----END PGP SIGNATURE-----