Re: some PyDO questions

Jacob Smullyan <[email protected]> Wed, 3 Aug 2005 08:44:14 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Wed, Aug 03, 2005 at 08:51:24AM +0200, [email protected] wrote:
> Hi,
> 
> I'm currently looking at using PyDO for some web applications in 
> combination with CherryPy and Oracle 9. So far I'm mostly happy, but I 
> have a few questions:
> 
> 1) Is it planned to include some sort of mapping functionality, to 
> customize how PyDO object's attributes are mapped to DB fields? This could 
> be pretty useful, as our DB structure and the field names are still 
> changing from time to time, and it's somewhat tedious to update all 
> scripts that use the respective attributes when their names change. I have 
> a few ideas about how to provide this myself - either by extending the 
> PyDO class and plugging in the mapping in the getSome/getUnique/update/... 
> methods, or by changing the PyDO package directly. I'm not too sure yet 
> what the best way is though, and it may be pointless to try this if it's 
> planned anyway.

If you mean to make it possible to keep separate the column name from
the Python field name, this is a possible feature for 2.1. I'm glad to
be reminded of this use case!  I think this feature needs to be
developed in tandem with some other enhancements to the Field class
and its api; currently the field "name" attribute is used for several
things which should be separated (sometimes you want the db name,
other times the python name).  Support for column aliases (in SQL, as
opposed to Python aliases) would also be useful.

If you need this now, putting it into a subclass is probably safest
for you, stability-wise; I welcome patches, but it will probably take
some negotiation to reconcile different patches into the final result.  

> 2) I noticed that DB fields aren't provided as attributes in PyDO classes, 
> only as dictionary entries. While this was easy to workaround (again by 
> providing a simple subclass of PyDO that extends the getSome and getUnique 
> methods and deriving all model classes from that class), I'm wondering if 
> this is a known bug? I'm using Python 2.4.1, cx_Oracle 4.1 and Oracle 9.2 
> on a Windows XP machine at the moment.

DB fields certainly are provided as attributes in PyDO instances in
the PyDO 2.0 series, unless use_attributes is set to False -- unless
you mean something quite different than I by fields or attributes.
Could you provide an example or a test that fails?

Cheers,

js



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

iD8DBQFC8LweuqamFyFXXLIRAhpJAJoCn7veRPuL4OpubcL/slOOTFabiwCfaMXA
65QguCMRVitNSMUn8dWkB1M=
=18wG
-----END PGP SIGNATURE-----