It seems when loading the new relation from a class declaration the
joinMethodName is not correctly used as (should be) set by sqlmeta. Is
this a bug, or am I using it incorrectly?
Overview of what I did and the problem and how to work around it:
1. Started with a dbase .py with something like this;
---
class <existing_table>( SQLObject ):
.. bla ..
.. bla ..
.. bla ..
---
2. then I added:
---
class <new_relation>( SQLObject ):
.. bla ..
.. bla ..
---
3. Then I did:
python
from my_dbase import existing_table, new_relation
existing_table.sqlmeta.addJoin( RelatedJoin( 'new_relation',
joinMethodName='lookatmynewclass' ) )
4. Then I changed my initial setup to:
---
class <existing_table>( SQLObject ):
.. bla ..
.. bla ..
.. bla ..
lookatmynewclass = RelatedJoin( 'new_relation' )
---
5. Now when I do:
---
my_object = existing_table.selectBy( mywhatever='something' )
print dir( my_object )
---
There is a attribute "new_relations" (new class + 's') instead of (what
I expected) "lookatmynewclass".
6. I have worked around this by changing my class definition to:
---
class <existing_table>( SQLObject ):
.. bla ..
.. bla ..
.. bla ..
lookatmynewclass = RelatedJoin( 'new_relation',
joinMethodName='lookatmynewclass' )
---
But this seems weird and illogical to me.
Is there a bug in sqlmeta or am I doing it completely wrong?
Either way, I have it working now.
Kind regards,
- Ramon.
P.S. This is with python 2.3 and sqlobject 0.7 on Debian Linux
Ramon Bastiaans wrote:
Hi all,
I am trying to add a new class/relation to a existing table/class. I
would like to do this without recreating all the tables (since they
contain data).
I have tried to use <existing_class>.sqlmeta.addJoin( RelatedJoin(
'<newclass>', joinMethodName='mynewproperties' ) ) from python on the
commandline.
This seems to work.
But then when I load the new relation in from the 'normal' class
definition in the source code, like this:
class <existing_class>:
.... bla bla...
mynewproperties = RelatedJoin( '<newclass>' )
And I select a object from the database, it doesn't seem to have a
'mynewproperties' attribute?
My guess is that sqlmeta is only supposed to add joins in runtime and
forgets them after runtime, so I can't re-use it.
Someone has any tips on how I can do this the easiest way? How can I
do this permanently?
Kind regards,
- Ramon.
--
There are really only three types of people:
Those who make things happen,
those who watch things happen,
and those who say, "What happened?"
---
ing. R. Bastiaans
HPC - Systems Programmer
SARA - Computing and Networking Services
Kruislaan 415 PO Box 194613
1098 SJ Amsterdam 1090 GP Amsterdam
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss