[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] [PyQt4] Bugs? Side effects of some python syntax on sqlite
From:       IloChab <ilochab () gmail ! com>
Date:       2008-09-27 13:34:15
Message-ID: 166b1c630809270634i3facaaa0g32bebb7020fe99ed () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


It's awhile that I'm struggling with a strange behavior of my code on
different platforms.

My program is a GUI to a sqlite db that uses PyQt4 API's to access it.
In different situations it looks like it is working correctly (no error,
coherent db management at run-time) but when it ends no db modification is
written to disk (and I find a db-journal nearby my db file).

At the beginning I noticed that it worked onto some platforms and it didn't
on others
[ http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14774.html ].

Then I found which was the part of code responsible for the wrong behavior
[ http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14883.html ].

After avoiding the use of lambda forms, and proceeding in my code
development, I found an other statement that produced exactly the same
problem: it was a simple reference to an owner object.
I will explain it.
1- when my application starts it instantiates a MainWindow object
2- in its __init__ it instantiates many QtGui.QTableView objects
3- in their __init__ they instantiate one QtSql.QSqlQueryModel object each
=> If I pass through all this chain a reference to the mainWindow object (as
init parameter) and I use it just in the subsequent. init-functions, every
thing works fine.
=> If I store this reference in a queryModel object attribute, for
subsequent. uses, every thing LOOKS LIKE it's functioning correctly, I don't
get any error, but at the end of the execution all sqlite modifications are
NOT written to disk and I find a db-journal file near by my db file. Note
that it's enough that I store the reference to the mainWindow object, it
doesn't matter if I don't or do use it.
I was able to bypass this problem using a weakref.ref(mainW) instead of a
plain reference

Does this make any sense to you or it is a bug?

I hope to receive a followup to my question even if I didn't to the previous
ones (perhaps my English is too bad and no one can understand it ???)


ciao

Licia

[Attachment #5 (text/html)]

<div dir="ltr">


	<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
	<title></title>
	<meta name="GENERATOR" content="OpenOffice.org 2.4  (Unix)">
	<style type="text/css">
	&lt;!--
		@page { size: 21cm 29.7cm; margin: 2cm }
		P { margin-bottom: 0.21cm }
	--&gt;
	</style>

<p style="margin-bottom: 0cm;">It&#39;s awhile that I&#39;m struggling with a
strange behavior of my code on different platforms.<br><br>My program
is a GUI to a sqlite db that uses PyQt4 API&#39;s to access it.<br>In
different situations it looks like it is working correctly (no error,
coherent db management at run-time) but when it ends no db
modification is written to disk (and I find a db-journal nearby my db
file).<br><br>At the beginning I noticed that it worked onto some
platforms and it didn&#39;t on others<br>[
<a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14774.html">http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14774.html</a>
 ].<br><br>Then I found which was the part of code responsible for the
wrong behavior<br>[
<a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14883.html">http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14883.html</a>
 ].<br><br>After avoiding the use of lambda forms, and proceeding in
my code development, I found an other statement that produced exactly
the same problem: it was a simple reference to an owner object.<br>I
will explain it.<br>1- when my application starts it instantiates a
MainWindow object<br>2- in its __init__ it instantiates many
QtGui.QTableView objects<br>3- in their __init__ they instantiate one
QtSql.QSqlQueryModel object each<br>=&gt; If I pass through all this
chain a reference to the mainWindow object (as init parameter) and I
use it just in the subsequent. init-functions, every thing works
fine.<br>=&gt; If I store this reference in a queryModel object
attribute, for subsequent. uses, every thing LOOKS LIKE it&#39;s
functioning correctly, I don&#39;t get any error, but at the end of the
execution all sqlite modifications are NOT written to disk and I find
a db-journal file near by my db file. Note that it&#39;s enough that I
store the reference to the mainWindow object, it doesn&#39;t matter if I
don&#39;t or do use it.<br>I was able to bypass this problem using a
weakref.ref(mainW) instead of a plain reference<br><br>Does this make
any sense to you or it is a bug?<br><br>I hope to receive a followup
to my question even if I didn&#39;t to the previous ones (perhaps my
English is too bad and no one can understand it ???)</p><p style="margin-bottom: \
0cm;"><br></p><p style="margin-bottom: 0cm;">ciao</p><p style="margin-bottom: \
0cm;">Licia<br></p> </div>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic