sqlobject-discuss Mailing List for SQLObject (Page 382)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Cary F. <ckf...@ho...> - 2004-05-25 12:08:34
|
What is the proper way to put data into this column? As a string? What format? I'm using mySQL. Thanks. _________________________________________________________________ MSN Toolbar provides one-click access to Hotmail from any Web page FREE download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/ |
From: Nick <ni...@dd...> - 2004-05-25 02:13:33
|
Use os.path.sep Nick On Mon, 2004-05-24 at 16:34, Ian Sparks wrote: > >From scouring the source (is connectionForURI documented anywhere?) I discover that the connectionForURI method takes an argument string something like : > > connectionForURI("<DB_TYPE>://<USERID>:<password>@<HOST>/<PATH>) > > so for a Firebird connection : > > connectionForURI("firebird://SYSDBA:masterkey@localhost/data/somewhere/my_db.gdb") > > but this seems broken on Windows if I want to connect to a DB on my D: drive : > > connectionForURI("firebird://SYSDBA:masterkey@localhost/D:/my_db.gdb") > > I get some error about an "undefined service d/tcp.." from kinterbasdb because its trying to open /D:/my_db.gdb and, naturally, gets confused > > I believe that the following (naive) patch against dbconnection.py will fix if inserted at line 95 : > > if path.find(':') != -1: > start,rest = path.split(':') > start = start.replace('\\','') > start = start.replace('/','') > path = start + ':' + rest > > There is probably a better way but this fixes it for me. > > Be good if something with the same effect could make it into 0.6 SVN. Thank you. > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id149&alloc_id66&op=click > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |
From: Ian S. <Ian...@et...> - 2004-05-24 21:34:53
|
From scouring the source (is connectionForURI documented anywhere?) I = discover that the connectionForURI method takes an argument string = something like : connectionForURI("<DB_TYPE>://<USERID>:<password>@<HOST>/<PATH>) so for a Firebird connection : connectionForURI("firebird://SYSDBA:masterkey@localhost/data/somewhere/my= _db.gdb") but this seems broken on Windows if I want to connect to a DB on my D: = drive : connectionForURI("firebird://SYSDBA:masterkey@localhost/D:/my_db.gdb") I get some error about an "undefined service d/tcp.." from kinterbasdb = because its trying to open /D:/my_db.gdb and, naturally, gets confused I believe that the following (naive) patch against dbconnection.py will = fix if inserted at line 95 : if path.find(':') !=3D -1: start,rest =3D path.split(':') start =3D start.replace('\\','') start =3D start.replace('/','') path =3D start + ':' + rest There is probably a better way but this fixes it for me. Be good if something with the same effect could make it into 0.6 SVN. = Thank you. |
From: ludwig z. <lu...@mu...> - 2004-05-22 17:32:32
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi just upgraded from 0.5.2 to the svn version. code like this: class Sub(SQLObject): ... class Person(Sub): _fromDatabase = True which used to work in 0.5.2, now produces: Traceback (most recent call last): File "test.py", line 31, in ? class Person(Sub): File "/usr/lib/python2.3/site-packages/sqlobject/main.py", line 159, in __new__ newClass.addColumnsFromDatabase() File "/usr/lib/python2.3/site-packages/sqlobject/main.py", line 460, in addColumnsFromDatabase for columnDef in cls._connection.columnsFromSchema(cls._table, cls): AttributeError: 'NoneType' object has no attribute 'columnsFromSchema' incidently, i found out that the following does work, though: class Sub(SQLObject): ... class SubSub(Sub):pass class Person(SubSub): _fromDatabase = True and actually, my current setup now requires a SubSubSub class... am i missing something? lg lu - -- >> http://lu.mur.at/lu.pub.key.html << -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAr46yea0RHHXBzw0RAvYBAJ4+pk03Rl9eFWD+5s7khW3EjRhr3ACfX4QD fSAisEkLZnmUTZWnZ82oS/E= =2Ut9 -----END PGP SIGNATURE----- |
From: <ben...@id...> - 2004-05-22 13:56:45
|
Dear Open Source developer I am doing a research project on "Fun and Software Development" in which I kindly invite you to participate. You will find the online survey under http://fasd.ethz.ch/qsf/. The questionnaire consists of 53 questions and you will need about 15 minutes to complete it. With the FASD project (Fun and Software Development) we want to define the motivational significance of fun when software developers decide to engage in Open Source projects. What is special about our research project is that a similar survey is planned with software developers in commercial firms. This procedure allows the immediate comparison between the involved individuals and the conditions of production of these two development models. Thus we hope to obtain substantial new insights to the phenomenon of Open Source Development. With many thanks for your participation, Benno Luthiger PS: The results of the survey will be published under http://www.isu.unizh.ch/fuehrung/blprojects/FASD/. We have set up the mailing list fa...@we... for this study. Please see http://fasd.ethz.ch/qsf/mailinglist_en.html for registration to this mailing list. _______________________________________________________________________ Benno Luthiger Swiss Federal Institute of Technology Zurich 8092 Zurich Mail: benno.luthiger(at)id.ethz.ch _______________________________________________________________________ |
From: Bjorn T. <bj...@ya...> - 2004-05-21 14:01:44
|
On Thu, May 20, 2004 at 05:37:41PM +0400, Oleg Broytmann wrote: > On Thu, May 20, 2004 at 03:30:05PM +0200, Bjorn Tillenius wrote: > > I'm using SQLObject in a project where I need unicode support. I would > > > > >>> class Word(SQLObject): > > ... value = StringCol() > > Just implemet your own column, say, UnicodeColumn. > value = UnicodeColumn() > > There are many ways you can redefine its behaviour. Using validators, > e.g. Thanks, that was what I was looking for. Regards, Bjorn |
From: Oleg B. <ph...@ma...> - 2004-05-20 13:37:59
|
On Thu, May 20, 2004 at 03:30:05PM +0200, Bjorn Tillenius wrote: > I'm using SQLObject in a project where I need unicode support. I would > > >>> class Word(SQLObject): > ... value = StringCol() Just implemet your own column, say, UnicodeColumn. value = UnicodeColumn() There are many ways you can redefine its behaviour. Using validators, e.g. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Bjorn T. <bj...@ya...> - 2004-05-20 13:30:06
|
Hello, I'm using SQLObject in a project where I need unicode support. I would like to be able get and set unicode strings directly to my classes' properties. That is, I want the following to work: >>> class Word(SQLObject): ... value = StringCol() >>> word = Word() >>> word.value = u'unicode string' >>> word.value u'unicode string' I know that I could override _set_value and _get_value in order to get it to work, but I rather not, since that would pollute my code. Would it be possible to add a 'encode/decode hook' similar to _style, which would encode and decode all values set and retrieved from SQLObjects? Or maybe it's possible to solve in some better way? BTW, I'm using the CVS version of SQLObject Regards, Bjorn |
From: Ian B. <ia...@co...> - 2004-05-19 15:52:35
|
Philippe Normand wrote: > Hi, > > Would anybody be interested in a sqlobject Debian package ? And which > version, 0.5.x or 0.6 ? There's already a package, but I think it was made around 0.3 and hasn't been updated. I've copied that author. I think 0.6 would be best. I've been bad -- I should really release 0.5.3, and call the trunk 0.6 and release it properly. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
From: Eduardo E. <eel...@na...> - 2004-05-19 14:53:02
|
Oops. I downloaded the 0.6 docs with the 0.5 tar.gz. Thank you, guys. Ed. Luke Opperman wrote: > in the 0.6/SVN branch, SysUser.get(id) exists (API change/addition), but > SysUser(id) will still work. (Ian, is this planned to be deprecated? I'm > trying to recall the implications of this API change - was > _init/construction > intended to be used to replace .new(), and get() the preferred way to > retrieve > existing objects?) > > if you are using 0.5.x, then Oleg's answer below is correct. > > - Luke > >>> >>> How can I load an existing instance? >> >> >>>>> u = SysUser(1) # just so simple ;) >> >> >> or, using your alternateID: >> >>>>> u = SysUser.byName("Eduardo") >> >> >> Oleg. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click |
From: Philippe N. <sw...@fr...> - 2004-05-19 11:53:17
|
Hi, Would anybody be interested in a sqlobject Debian package ? And which version, 0.5.x or 0.6 ? --=20 Philippe Normand | base-art dot net |
From: Luke O. <lu...@me...> - 2004-05-19 07:22:54
|
in the 0.6/SVN branch, SysUser.get(id) exists (API change/addition), but SysUser(id) will still work. (Ian, is this planned to be deprecated? I'm trying to recall the implications of this API change - was _init/construction intended to be used to replace .new(), and get() the preferred way to retrieve existing objects?) if you are using 0.5.x, then Oleg's answer below is correct. - Luke >> >> How can I load an existing instance? > >>>> u = SysUser(1) # just so simple ;) > > or, using your alternateID: > >>>> u = SysUser.byName("Eduardo") > > Oleg. |
From: Oleg B. <ph...@ma...> - 2004-05-19 05:26:13
|
On Tue, May 18, 2004 at 06:16:10PM -0400, Eduardo Elgueta wrote: > >>> from SQLObject import * > >>> __connection__ = MySQLConnection(name = 'system_conn', user = > 'user', passwd = 'pass', host = 'host', db = 'db', debug = True) > >>> class SysUser (SQLObject): > ... name = StringCol(length=10, alternateID=True) > ... > >>> u = SysUser.get(1) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: type object 'SysUser' has no attribute 'get' > > How can I load an existing instance? >>> u = SysUser(1) # just so simple ;) or, using your alternateID: >>> u = SysUser.byName("Eduardo") Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Eduardo E. <eel...@na...> - 2004-05-18 22:16:21
|
Hi All, >>> from SQLObject import * >>> __connection__ = MySQLConnection(name = 'system_conn', user = 'user', passwd = 'pass', host = 'host', db = 'db', debug = True) >>> class SysUser (SQLObject): ... name = StringCol(length=10, alternateID=True) ... >>> u = SysUser.get(1) Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: type object 'SysUser' has no attribute 'get' How can I load an existing instance? TIA. Ed. |
From: Luke O. <lu...@me...> - 2004-05-13 17:49:31
|
Quoting Peter Gebauer <pet...@st...>: > > myDataStruct = new SomeSQLObject() > .. set some attributes from web forms, store it in a session, etc .. > myDataStruct.save() > > Or similar... :) > > Has anyone implemented a way to do this? A long time ago I wrote something that did this. I'll send you the code if you want, but I can't say how useful it will be. But here's the conceptual path I took. The basic idea was a DBAPI/DBConnection compatible class that stored everything in memory. Tables/values were internally kept as lists/dictionaries. I left out all of the select and create/drop table/column stuff. I guess you might be able to make a case for implementing select, but I didn't need it, and it makes things much tougher (actually have to implement some SQL). Creating new objects in the MemoryConnection was simple, except you don't know what ID to give yet. I used negative ints, to be converted at commit/save time with queryInsertID. Editing an existing object was a matter of creating the object in the MemoryConnection and then doing a _selectInit with the results of the object's previous connection. Joins and ForeignKeys were the real issue: for newly created objects, you need to run through and update any related objects with it's new ID. If a join list is changed for an existing object, now you need to do queries that combine both the existing unmodifed objects (not part of MemoryConnection) and any additions/deletions pending in the MemoryConnection. Basically, newly created/updated intersection records and previously existing deleted records are stored in the MemoryConnection, but most of the results exist in the original connection, perform some set operations to merge the changes. You'll need to have the original connection available most of the time because of that, making it break the seamless appearance of an SQLObject at some point if you need to store to session/retrieve (unless connectionURIs make that feasible; i really need to play with the latest version of SO). I think that's about it. At the time, issues with SQLObject's cache were making it difficult to update existing instances of the objects once they are committed/saved out of the MemoryConnection. I think those are cleared up now: need a way to obsolete all existing instances of an object and make them go back to the cache/database for values. I think that about covers where I went with this. It was functional at one time, but I haven't had a case to use it since. - Luke |
From: Peter G. <pet...@st...> - 2004-05-13 16:46:18
|
Hello! I asked several months ago if there was a way to use SQLObjects without having a row-representative in the backend database. That is, I have a need to instanciate and use a SQLObject and manipulate the attributes for that instance without actualy making changes. Sort of: myDataStruct = new SomeSQLObject() .. set some attributes from web forms, store it in a session, etc .. myDataStruct.save() Or similar... :) Has anyone implemented a way to do this? Best regards, Peter Gebauer |
From: Eduardo E. <eel...@na...> - 2004-05-13 13:05:29
|
Thanx Oleg Broytmann wrote: >On Wed, May 12, 2004 at 06:24:19PM -0400, Eduardo Elgueta wrote: > =20 > >>How do I order by more than one column. >>Trying orderBy=3D'field1, field2' produces >> =20 >> > > orderBy=3D['field1', 'field2'] > >Oleg. > =20 > --=20 Eduardo Elgueta Senior Consultant Navix correo/email: eel...@na... tel=E9fono/phone: +56 (2) 204-5823 celular/mobile: +56 (9) 821-0033 web: www.navix.cl Av. Pedro de Valdivia 555 Of. 216 Providencia 7500913 Santiago, Chile |
From: Oleg B. <ph...@ma...> - 2004-05-13 07:50:39
|
On Wed, May 12, 2004 at 06:24:19PM -0400, Eduardo Elgueta wrote: > How do I order by more than one column. > Trying orderBy='field1, field2' produces orderBy=['field1', 'field2'] Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Eduardo E. <eel...@na...> - 2004-05-12 22:24:26
|
Hi All, How do I order by more than one column. Trying orderBy='field1, field2' produces AssertionError: Strings in clauses are expected to be column identifiers. I got: 'field1, field2' Thanx Ed. |
From: Eduardo E. <eel...@na...> - 2004-05-12 15:35:42
|
David Warnock wrote: > Luke, > > A lot depends on the problem domain. In a corporate environment the > database is often used by multiple applications and has a longer life > than individual applications. Therefore logic in the database is cheaper. > > Anyway, if you dbms does not have triggers choose a proper dbms ;-) I don't agree. In my case, it used to be so two or three years ago. Nowadays, most of my customers want business objects residing in an application server and I've been relatively successful implementing this concept with Webware/Python (and this is why I'm starting to use SQLObejct). In fact, thats the whole idea in Java EE and Web Services, in which I've completely achieved that: various applications/clients using an application object implementing business rules. Part of the explanation for this is databases are not that "stable" any more. For instance, one of my customers (a large company, by my country standards) is favoring MS SQL Server, because of Oracle licensing price changes. Now they find they have to migrate database code if they want to get rid of Oracle. Other customers are migrating to OS database systems (MySQL, Postgres). Yet, other customers complain when the find their application code is not "centralized", but scattered in application programs, database code and batch tasks. The new rationale is: let's put the code in application code, so we get a single application source which we don't have to migrate/rewrite the next time we upgrade/switch DBMS (Oracle/SQL Server to OSDMBS) or client (windows, html/javascript, WAP, etc). > Maybe one day there could even be a deployment option to choose which > SQLObject code runs in the client and which in the dbms as triggers ;-) > > Dave By the time being, I would be very grateful if someone can give some pointers on how to implement this trigger functionality for SQLObject. Luke has given me some. May be later I could post a patch or something in return for the help. Regards. Ed. |
From: David W. <da...@su...> - 2004-05-12 02:04:17
|
Luke, > But a large part of the draw of SQLObject is database independence. Some > databases do not support triggers, and most that do having varying > levels of > support. H'mm, yes that is one aspect of a tool like SQLObject, but there are others such as ease of updating application to revised database structure. A lot depends on the problem domain. In a corporate environment the database is often used by multiple applications and has a longer life than individual applications. Therefore logic in the database is cheaper. Anyway, if you dbms does not have triggers choose a proper dbms ;-) > Instead, what if SQLObject (or an agnostic module) provided an object-level > concept of triggers? Like the idea of putting constraints on the python > side, > this would both allow us to implement functionality that is missing from > most > of the databases we work with, and be able to transport between database > systems. There are other areas to improve as well in becoming a completely > database-agnostic data management system, and I'd like to make it act more > relational than network-based where reasonable. But triggers is as good a > place to start as any. I would agree. Generic places to put code for for validation, calculation, integrrity checks, security checks, cross db updates, mailing updates, replication, auditing etc are all essential. Maybe one day there could even be a deployment option to choose which SQLObject code runs in the client and which in the dbms as triggers ;-) Dave -- David Warnock, Sundayta Ltd. http://www.sundayta.com iDocSys for Document Management. VisibleResults for Fundraising. Development and Hosting of Web Applications and Sites. |
From: Luke O. <lu...@me...> - 2004-05-12 00:21:38
|
I agree with you that currently his best bet is in-database triggers. And if you use PostgreSQL, your triggers can even be written in python. But a large part of the draw of SQLObject is database independence. Some databases do not support triggers, and most that do having varying levels of support. Instead, what if SQLObject (or an agnostic module) provided an object-level concept of triggers? Like the idea of putting constraints on the python side, this would both allow us to implement functionality that is missing from most of the databases we work with, and be able to transport between database systems. There are other areas to improve as well in becoming a completely database-agnostic data management system, and I'd like to make it act more relational than network-based where reasonable. But triggers is as good a place to start as any. Triggers and constraints are part of the same ideas, and contraints may be a logical place to add generic triggers. Single column constraints Inter-column constraints Single table constraints Inter-table constraints And a few others I can't think of right now. But it starts to illustrate why simply adding insert/update/delete triggers doesn't satisfy. Thoughts to think about, I won't make any commitments to starting to implement these things, but maybe someone else is interested, I'll certainly carry on discussion. - Luke Quoting David Warnock <da...@su...>: > It seems to me that this type of logic is best (for performance and so > that all database updates are audited) and simplest written as triggers > in the database. > > Why not? There are several free databases that support triggers such as > Firebird and Postgesql. |
From: David W. <da...@su...> - 2004-05-11 23:14:46
|
Ed, > I have some basic audit fields in my tables, that I used to update in my > rudimentary ORM superclass. It seems to me that this type of logic is best (for performance and so that all database updates are audited) and simplest written as triggers in the database. Why not? There are several free databases that support triggers such as Firebird and Postgesql. Regards Dave -- David Warnock, Sundayta Ltd. http://www.sundayta.com iDocSys for Document Management. VisibleResults for Fundraising. Development and Hosting of Web Applications and Sites. |
From: Eduardo E. <eel...@na...> - 2004-05-11 22:50:39
|
Luke Opperman wrote: > It's been a while since I've done this (ie, a couple revs of SQLObject=20 > ago), > but the limitations on inheritance in SQLObject have always been about > concrete classes, and since 0.4 or so, abstract columns could be=20 > inherited. It > is quite possible to define common elements in abstract base classes,=20 > I use it > regularly to have a common _connection. Again, the subclassing=20 > limitation is > that every subclass table will be expected to actually have those=20 > columns, but > I think that's exactly your situation. That's right. > > So (untested) I think this will do what you want for *create*: > > class MainObject(SQLObject): > createdBy =3D StringCol(default=3D"me") > createdOn =3D DateTimeCol(default=3Dnow) > > class MyObjOne(MainObject): > otherColumn =3D ... > > class MyObjTwo(MainObject): > someColumn =3D ... > > > (Note the default=3Dnow, not default=3Dnow() - SQLObject will use it as= a=20 > callback > since you don't want the value of now() as of creation time, but at=20 > insert). > Shouldn't have to override anything else, the default will be inserted=20 > if you > ignore those column names for your subclasses. Ok. > > Now, for update you'd have to override _SO_setValue() and set(). (Again= , > untested, and based on 0.5 that I have in front of me.) I'm going to=20 > treat all > _SO_setValue calls as effectively set() calls, since we now have multip= le > values. > > > class MainObject(SQLObject): > createdBy =3D StringCol(default=3D"me") > createdOn =3D DateTimeCol(default=3Dnow) > updateBy =3D StringCol(default=3D"me") > updateOn =3D DateTimeCol(default=3Dnow) > > def _SO_setValue(self, name, value, fromPython): > if fromPython: > value =3D fromPython(value, self._SO_validatorState) > updates =3D {'updateBy': "me", 'updateOn': now(), name: value} > self.set(**updates) > > def set(self, **kw): > if not kw.get('updateOn',None): > kw['updateOn'] =3D now() > if not kw.get('updateBy',None): > kw['updateBy'] =3D "me" > super(MainObject, self).set(**kw) > > > Disclaimer again: this is looking at SO 0.5, I'm not sure I really=20 > like it, it > would be nice to write a database-agnostic trigger system as part of > SQLObject. But I certainly don't have the time for it (it was was=20 > mentioned on > the list a long time ago, nothing really came of it). > I understand this may not work. I'll see if it applies to the release I=20 have. However, I'm wondering why you have to override _SO_setValue and=20 set. I think set does all the job. And second, from that code It seems to me that the call to self.onUpdate=20 should be made in the set method, because (I think) every field update=20 goes through this code. Obviously, it'd be better to have that event=20 function called once, right before sending the sql statment to the=20 database, but this would be enough for me, at least by now. > And my example may not work at all because of something I've forgotten. > Hopefully it gets you on a workable track though. > > - Luke > Thank you very much. Ed. > Quoting Eduardo Elgueta <eel...@na...>: > >> Oleg and anyone else, >> >> I tried Daniel Savard's patch and I can see I could use it to achieve >> what I want, but creating an unnatural hierarchy. >> >> What I would like to have is something like this: >> >> def MyOnUpdate (sqlObj): >> sqlObj.addColumn(StringCol("updateBy", "me"); >> sqlObj.addColumn(DateTimeCol("updateOn", now()); >> >> def MyOnInsert (sqlObj): >> sqlObj.addColumn(StringCol("createdBy", "me"); >> sqlObj.addColumn(DateTimeCol("createdOn", now()); >> MyOnUpdate(sqlObj) >> >> def MySQLObject1 (SQLObject): >> myField =3D StringCol() >> onInsert =3D MyOnInsert(self) >> onUpdate =3D MyOnUpdate(self) >> >> def MySQLObject2 (SQLObject): >> myField =3D IntCol() >> onInsert =3D MyOnInsert(self) >> onUpdate =3D MyOnUpdate(self) >> >> What I need is to find the place to insert the self.onUpdate(self) cal= l. >> Any suggestion? >> >> TIA, >> >> Ed. >> >> PS: In other words, I need triggers which MySQL (my database backend) >> does not provide. >> >> Eduardo Elgueta wrote: >> >>> Oleg, >>> >>> Thank you for your answer. >>> >>> I'm not sure inheritance is what I need, but I'll certainly give it=20 >>> a try. Where can I get that patch? >>> >>> Ed. >>> >>> Oleg Broytmann wrote: >>> >>>> On Mon, May 10, 2004 at 05:37:21PM -0400, Eduardo Elgueta wrote: >>>> >>>>> I have some basic audit fields in my tables, that I used to update=20 >>>>> in my rudimentary ORM superclass. >>>>> >>>>> I've seen in the FAQ/docs that SQLObject classes are not meant to=20 >>>>> be subclassed >>>> >>>> >>>> >>>> >>>> There was a Daniel Savard's inheritance patch. I cannot find it o= n >>>> the web, but I have patches for SQLObject 0.5.1 and 0.5.2. >>>> >>>> Oleg. >>> >>> >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by Sleepycat Software >>> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to=20 >>> deliver higher performing products faster, at low TCO. >>> http://www.sleepycat.com/telcomwpreg.php?From=3Dosdnemail3 >> >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by Sleepycat Software >> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to >> deliver higher performing products faster, at low TCO. >> http://www.sleepycat.com/telcomwpreg.php?From=3Dosdnemail3 >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > > > > > --=20 > The Pursuit of Counterfactual Histories > --=20 Eduardo Elgueta Senior Consultant Navix correo/email: eel...@na... tel=E9fono/phone: +56 (2) 204-5823 celular/mobile: +56 (9) 821-0033 web: www.navix.cl Av. Pedro de Valdivia 555 Of. 216 Providencia 7500913 Santiago, Chile |
From: Eduardo E. <eel...@na...> - 2004-05-11 22:36:16
|
Oleg, I want to achieve trigger functionality: to call some function when data is about to be committed to the database, and have the chance to modify some values. See Luke's response. Thanks. Ed. Oleg Broytmann wrote: > On Tue, May 11, 2004 at 05:24:05PM -0400, Eduardo Elgueta wrote: > >>My mistake. I meant this: > > > Too much code. But what do you want to achieve? > > Oleg. |