Herwig Hochleitner | 5 Jun 23:21
Picon
Gravatar

transactions; cache sync behavior; sqlite3 relatet?

Hi!

Attached is a small code snippet highlighting some strange behavior.
It outputs:

Writing 'connection_val' to connection foo
Value of transaction foo: 'init'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'

Instead of the expected:

Writing 'connection_val' to connection foo
Value of transaction foo: 'connection_val'
Writing 'transaction_val' to transaction foo
Value of connection foo: 'connection_val'

Is this behavior intentional? (ie can I rely on it)
Is is sqlite3 related? (right now I can't test it on another DB)

How should I fix this?
.expire()? .sync()?
Invalidate the transaction's cache?

Caching behavior in sqlobject looks like some can worms to me.

regards
Herwig Hochleitner

(Continue reading)

Oleg Broytmann | 6 Jun 00:25
X-Face
Picon
Favicon

Vacation

Hello! I'm leaving the town for a vacation. Will be back at June 20. Please
help each other.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
Oleg Broytmann | 6 Jun 00:46
X-Face
Picon
Favicon

Re: transactions; cache sync behavior; sqlite3 relatet?

I'll try to answer briefly and then will leave the computer...

On Fri, Jun 05, 2009 at 11:21:49PM +0200, Herwig Hochleitner wrote:
> Writing 'connection_val' to connection foo
> Value of transaction foo: 'init'
> Writing 'transaction_val' to transaction foo
> Value of connection foo: 'connection_val'

> import sqlobject
> # Turn off caching so that multiple connections (ie transactions) sync properly
> conn = sqlobject.connectionForURI("sqlite:/:memory:", debug=True, logger="database.query",
loglevel="debug", cache=False)
> class Dummy(sqlobject.SQLObject):
>     foo = sqlobject.StringCol()
> Dummy.createTable(connection=conn)
> Dummy(foo="init", connection=conn)
> tr = conn.transaction()
> conn_dummy=Dummy.get(1,conn)
> trans_dummy=Dummy.get(1,tr)
> print "Writing 'connection_val' to connection foo"
> conn_dummy.foo = "connection_val"
> print "Value of transaction foo: '%s'" % trans_dummy.foo

   AFAIU, what is going on there is:

-- the code opens the first connection (without a transaction);
-- a new table is created via connection 1;
-- a new row is inserted via connection 1;
-- the code opens another connection, and BEGINs a transaction ;
-- the code draws two copies of the row via connection1 and connection2;
(Continue reading)

Herwig Hochleitner | 6 Jun 12:20
Picon
Gravatar

Re: transactions; cache sync behavior; sqlite3 relatet?

Thanks for your answer

I messed up the code snippet; forgot the commit.
Please check updated attachment.
>    AFAIU, what is going on there is:
>
> -- the code opens the first connection (without a transaction);
> -- a new table is created via connection 1;
> -- a new row is inserted via connection 1;
> -- the code opens another connection, and BEGINs a transaction ;
> -- the code draws two copies of the row via connection1 and connection2;
> -- the code changes the attribute .foo of the FIRST copy;
> -- the code prints the attribute .foo of the SECOND copy that was drawn via
>    another transaction, and the value is still 'init' because it isn't
>    changed - the code hasn't changed trans_dummy.foo yet.
>   
I intended to illustrate following behavior:

Two instances of the same class with same id; one pulled via a 
connection (with cache=False); one pulled via a transaction createt from 
that same connection;
--> Commits to the transaction _do_ invalidate the instance pulled via 
connection (thanks to cache=False);
--> Changes to the connection instance _don't_ invalidate the 
transaction instance;

This asymmetric behavior seems strange to me, since (as far as i 
understood the code), the transaction object even uses the same cache; 
it's using the same DBConnection instance, after all.

(Continue reading)

Daniel Fetchinson | 9 Jun 03:16

Re: Vacation

> Hello! I'm leaving the town for a vacation. Will be back at June 20. Please
> help each other.
>
> Oleg.

Have fun!

Cheers,
Daniel

--

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
Sam's Lists | 11 Jun 03:06
Picon
Gravatar

longId=True handling...

I posted this on the TurboGears mailing list but now I'm posting it here in hopes for more help.

Essentially I am upgrading from SQLObject 0.7.1dev_r1653 and MySQL 4.x something to MySQL 5 something and SQLObject 0.10.6

I have this very complicated legacy TurboGears application that I'm
tasked with upgrading to 1.0.8 which has laid stagnant since the days
of early .99 series.

The original author used the following a lot in his table definitions:

class sqlmeta:
        style = MixedCaseStyle(longID=True)

What this means is that instead of the id column being named 'id' it
takes on the name of the table...so if the table is called EventQueue,
the id column name is EventQueueID.

So far so good....but here's where it gets weird.

It appears that under the really old versions of TurboGears one could
refer to this EventQueueID as just .id and everything would work the
way you want it to.  (This appears to only be done in the app under
kid templates).

But now, under TG 1.0.8/the latest version of SQLObject that doesn't work.  Either I have to rename the
column to id or I have to refer to it as EventQueueID.

How can I make sqlObject seemlessly let me refer to columns named in
the long style just using id?

Thanks


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Sam's Lists | 11 Jun 06:39
Picon
Gravatar

Quoting reserved column names...

So I keep humming along on this upgrade of someone else's code from old versions of SQLObject and Mysql to the current SQLObject and MySQL 5...

The current problem is that I have a table with the column name 'condition' which apparently is not a reserved word in MySQL 4.0 but is a reserved word in 5.0.

When SQLObject translates its stuff to sql it does not put quotes
around the column names.  If it only would everything would work fine.

I could rename the column, but the word is used a lot in the program
in different ways, so it will get confusing to make sure I only change
the right ones .

Is there a way to force SQLObject to quote it properly?

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Simon Cross | 11 Jun 10:27
Picon

Re: longId=True handling...

On Thu, Jun 11, 2009 at 3:06 AM, Sam's Lists<samslists <at> gmail.com> wrote:
> How can I make sqlObject seemlessly let me refer to columns named in
> the long style just using id?

I think this is more of a Python question than a SQLObject question,
although it may be a little trickier in the SQLObject case because
SQLObject already uses a lot of attribute magic.  One approach might
be to just add .id properties to all your classes:

>>> class EventQueueID(object):
...     def __init__(self):
...         self.EventQueueID = 5
...

>>> e = EventQueueID()
>>> e.id
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'EventQueueID' object has no attribute 'id'

>>> def getid(self):
...     return getattr(self, self.__class__.__name__)
...
>>> def setid(self, x):
...     return setattr(self, self.__class__.__name__, x)
...
>>> EventQueueID.id = property(fget=getid, fset=setid)

>>> e.id
5
>>> e.id = 7
>>> e.id
7

I don't know if SQLObject has any magic that would break this, but I
think it should work.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
jonhattan | 11 Jun 10:23
Gravatar

Re: Quoting reserved column names...

Sam's Lists escribió:
> So I keep humming along on this upgrade of someone else's code from 
> old versions of SQLObject and Mysql to the current SQLObject and MySQL 
> 5...
>
> The current problem is that I have a table with the column name 
> 'condition' which apparently is not a reserved word in MySQL 4.0 but 
> is a reserved word in 5.0.
>
> When SQLObject translates its stuff to sql it does not put quotes
> around the column names.  If it only would everything would work fine.
>
> I could rename the column, but the word is used a lot in the program
> in different ways, so it will get confusing to make sure I only change
> the right ones .
>
> Is there a way to force SQLObject to quote it properly?
>
you can force the name of the column in the database this way:

condition = StringCol(dbName='_condition')

> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing 
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> ------------------------------------------------------------------------
>
> _______________________________________________
> sqlobject-discuss mailing list
> sqlobject-discuss <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>   

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
Christian Schwartze | 11 Jun 11:30
Picon
Picon
Favicon

Call a function in a schema

Dear sqlobject users,
 
Is it possible to call functions with func() in a postgresql schema other than the public one? I am using SQLObject 0.10.
Thanks a lot for your help!
 
Regards,
Christian.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane