Now that I have the variable 'projname' visible among modules, I'm trying
to find why one specific module cannot find an attribute in an imported
class. Other modules find it and order of listing the import statements does
not affect the error generation on this one page. No matter how many times I
look, I don't see what's different.
File "/data1/eikos/policyPage.py", line 135, in setUpTree
DBtools.cur.execute("select * from component where category='natural';")
AttributeError: class DBtools has no attribute 'cur'
The class DBtools does have the sqlite cursor attribute, and two other
modules (the main application one and another notebook page) use the same
reference without a complaint.
File "/data1/eikos/policyPage.py", line 135, in setUpTree
DBtools.cur.execute("select * from component where category='natural';")
AttributeError: class DBtools has no attribute 'cur'
The class DBtools does have the sqlite cursor attribute, and two other
modules (the main application one and another notebook page) use the same
reference without a complaint.
I could be way off here, and I suppose it depends on how these files are used elsewhere, but it seems like the OnOpenDB method (where cur is defined) of DBTools never gets called before the setUpTree method of modPolicy, and this is where DBTools.cur is referenced. Does that make any sense?
Also, a side note: it's not necessary to include the semicolon in your queries, but I suppose if it works, it doesn't hurt to leave them in.
I could be way off here, and I suppose it depends on how these files are
used elsewhere, but it seems like the OnOpenDB method (where cur is
defined) of DBTools never gets called before the setUpTree method of
modPolicy, and this is where DBTools.cur is referenced. Does that make any
sense?
John,
Ah, yes. I think you hit it dead center. The application will not start,
and I'm trying to load data when the source is not yet specified. Sigh. I
knew I was too close to see the problem.
I need to add a test so if projname is blank, those statements do not
execute.
Also, a side note: it's not necessary to include the semicolon in your
queries, but I suppose if it works, it doesn't hurt to leave them in.
Oh. OK. I mimic the syntax of using SQLite3 from the command line.
Many thanks!
Rich
···
On Fri, 3 Nov 2006, John Salerno wrote:
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
You’re on the right track but you just haven’t went far enough.
The separation between database code and wx code is a GoodThing TM but try to make it more even more meaningful. For example, database methods should not point to an event but to a query. Don’t use go naming then “WhenThisHasHappened” but “GiveMeThis” and “UpdateThat”…
When you do this you will realize that for a query to work there has to be a valid connection and a valid cursor… and all the code of the query should be in the database code… and THEN you will find that your query code is working all the time and is not influenced by EVENTS but by data.
The way I do it is make DBTools a TRUE Model object with initialization that creates the connection and the cursor… and with methods that use those.
Now that I have the variable ‘projname’ visible among modules, I’m trying
to find why one specific module cannot find an attribute in an imported
class. Other modules find it and order of listing the import statements does
not affect the error generation on this one page. No matter how many times I
look, I don’t see what’s different.
File “/data1/eikos/policyPage.py”, line 135, in setUpTree
DBtools.cur.execute
(“select * from component where category=‘natural’;”)
AttributeError: class DBtools has no attribute ‘cur’
The class DBtools does have the sqlite cursor attribute, and two other
modules (the main application one and another notebook page) use the same
reference without a complaint.
policyPage.py and dbMethods.py are attached.
TIA,
Rich
–
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.™ | Accelerator