On Jul 11, 2010, at 10:04 AM, Harry Percival wrote:

> thanks Michael.  I took a look at README.unittests, but had some difficulties 
> running them with ironpython (ipy setup.py test fails, and nosetests.exe 
> doesn't allow you to specificy an interpreter).  Still, i found some help on 
> the interwebs, as well as in the nose __init__.py.  eventually i was able to 
> run the tests by running the following script:
> 
> import sys, os
> #import ironclad #not needed. i think.
> 
> sys.path.append(r'C:\Python26\lib')
> 
> #now load Jeff Hardys sqlite dll which is in sqlite folder (sqlite not 
> supported on ipy)
> sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),'sqlite'))
> 
> import clr
> clr.AddReference('IronPython.SQLite')
> 
> #load plugin
> from sqlalchemy.test.noseplugin import NoseSQLAlchemy
> 
> from nose import main
> if __name__ == '__main__':
> 
>     main(addplugins=[NoseSQLAlchemy()])
> 
> cf 
> http://stackoverflow.com/questions/3198500/how-to-use-nose-with-ironpython/3223278#3223278
> 
> 
> Here's the summary:
> 
> Ran 1862 tests in 141.873s
> FAILED (SKIP=7, errors=1483, failures=52)
> 
> oh dear!  and yet, it seemed to be working pretty well until i ran into this 
> problem with mutli-table mapping.  Also, Jeff Hardy's porting of sqlite is 
> still in development, so it may be the cause of a few errors... might take a 
> look at 

Usually one thing goes wrong right at the start which blows up the state of the 
current engine, or some aspect of the test fixture doesn't work correctly.    
When porting to a new platform, the initial goal is to get just one small set 
of tests to run, the best place to start is test.sql.test_query since it issues 
some basic round trips.    (this is also in the README regarding new dialects).




> 
> 
> 
> On Sat, Jul 10, 2010 at 6:11 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
> 
> On Jul 10, 2010, at 12:07 PM, Harry Percival wrote:
> 
>> OK, just in case anyone else is foolishly trying  to run SQLA on ironpython, 
>> here's the workaround I've found:
>> 
>> instead of attempting to use the mapper directly on the join:
>> 
>> j = join(movies_table,md_table).join(directors_table)
>> mapper(MoviesAndDirectors,j) #ipy errors here
> 
>> use a mapper on a select based on the join:
>> 
>> mapper(MoviesAndDirectors,j.select(use_labels=True).alias('moviesanddirectors'))
>> 
>> seems to be working ok for now.
>> 
>> one final, polite plea - how can i run the sqla test suite, to see what 
>> other bugs might be lurking?
> 
> running the tests is fully described in README.unittests
> 
> 
> 
> 
>> 
>> cheers,
>> Harry
>> 
>> 
>> On Thu, Jul 8, 2010 at 10:52 AM, Harry Percival <harry.perci...@gmail.com> 
>> wrote:
>> Here's the source code of my test - let me know if I'm doing anything wrong 
>> here
>> 
>> from sqlalchemy import create_engine
>> from sqlalchemy.orm import mapper
>> from sqlalchemy.sql.expression import join
>> from sqlalchemy.orm.session import sessionmaker
>> from sqlalchemy.schema import MetaData
>> import traceback
>> 
>> try:
>>     import clr
>>     import os
>>     import sys
>>     sys.path.append(os.path.join(os.path.abspath(os.path.curdir),'sqlite'))
>>     clr.AddReference('Ironpython.Sqlite')  #need this for sqlite to work on 
>> ironpython. refers to a dll in zip file.
>> except:
>>     #not ipy
>>     pass
>> #from sqlalchemy.ext.sqlsoup import SqlSoup #sqlsoup also errors
>> 
>> engine = create_engine('sqlite:///moviedemo_simple.db3')  #moviedemo file 
>> also in zip file.
>> Session = sessionmaker(bind=engine)
>> class Movies(object):
>>     pass
>> class Directors(object):
>>     pass
>> class Genres(object):
>>     pass
>> class MoviesAndDirectors(object):
>>     pass
>> 
>> meta = MetaData()
>> meta.reflect(bind=engine)
>> all_tables = meta.tables
>> 
>> movies_table = all_tables['movies']
>> genres_table = all_tables['genres']
>> directors_table = all_tables['directors']
>> md_table = all_tables['movie_directors']
>> 
>> mapper(Movies,movies_table)
>> mapper(Directors,directors_table)
>> mapper(Genres,genres_table)
>> 
>> session = Session()
>> print session.query(Movies).all()[0]
>> print session.query(Directors).all()[0]
>> 
>> j = join(movies_table,md_table).join(directors_table)
>> try:
>> 
>>     mapper(MoviesAndDirectors,j)#ipy errors here
>>     mad1 = session.query(MoviesAndDirectors).all()[0]
>>     print mad1
>> except Exception, e:
>>     print 'caught exception',e
>>     last_error = e
>>     traceback.print_exc()
>> 
>> how can i run the sqlalchemy test suite?  I see it needs nose, i've 
>> installed that.  but i'm not clear what command to run to launch tests.
>> 
>> rgds,
>> harry
>> 
>> 
>> On Tue, Jul 6, 2010 at 6:40 PM, Harry Percival <harry.perci...@gmail.com> 
>> wrote:
>> Hi Michael,
>> 
>> thanks for replying - the reason I attached a zipfile is because sqlite 
>> isn't supported natively on ironpython, so I've had to include the source 
>> and a dll for it.  So, if you did have time to open it up and take a peek, 
>> I'd very much appreciate it.
>> 
>> Alternatively, how can I run the sqla unit tests?
>> 
>> 
>> On Tue, Jul 6, 2010 at 3:56 PM, Michael Bayer <mike...@zzzcomputing.com> 
>> wrote:
>> 
>> On Jul 6, 2010, at 4:18 AM, Harry Percival wrote:
>> 
>>> Hi,
>>> 
>>> I've got an error which occurs in ironpython but not in cpython. can anyone 
>>> replicate?  See attached. I'm using IPY 2.6.
>>> 
>>> <string>:1: DeprecationWarning: object.__init__() takes no parameters for 
>>> type _keyed_weakref
>>> <string>:1: DeprecationWarning: object.__init__() takes no parameters for 
>>> type KeyedRef
>>> <Movies object at 0x0000000000000034>
>>> <Directors object at 0x0000000000000038>
>>> caught exception 'NoneType' object has no attribute 'set'
>>> Traceback (most recent call last):
>>>  File "D:\workspace\resolver\test_multitable.py", line 54, in <module>
>>>    mapper(MoviesAndDirectors,j)#ipy errors here
>>>  File "D:\workspace\resolver\sqlalchemy\orm\__init__.py", line 818, in 
>>> mapper
>>>    return Mapper(class_, local_table, *args, **params)
>>>  File "D:\workspace\resolver\sqlalchemy\orm\mapper.py", line 210, in 
>>> __init__
>>>    self._configure_properties()
>>>  File "D:\workspace\resolver\sqlalchemy\orm\mapper.py", line 563, in 
>>> _configure_properties
>>>    self._configure_property(column_key,
>>>  File "D:\workspace\resolver\sqlalchemy\orm\mapper.py", line 755, in 
>>> _configure_property
>>>    prop.instrument_class(self)
>>>  File "D:\workspace\resolver\sqlalchemy\orm\properties.py", line 87, in 
>>> instrument_class
>>>    attributes.register_descriptor(
>>>  File "D:\workspace\resolver\sqlalchemy\orm\attributes.py", line 1424, in 
>>> register_descriptor
>>>    manager.instrument_attribute(key, descriptor)
>>>  File "D:\workspace\resolver\sqlalchemy\orm\attributes.py", line 1012, in 
>>> instrument_attribute
>>>    self.install_descriptor(key, inst)
>>>  File "D:\workspace\resolver\sqlalchemy\orm\attributes.py", line 1054, in 
>>> install_descriptor
>>>    setattr(self.class_, key, inst)
>>>  File "D:\workspace\resolver\sqlalchemy\orm\attributes.py", line 151, in 
>>> __set__
>>>    self.impl.set(instance_state(instance), instance_dict(instance), value, 
>>> None)
>>> AttributeError: 'NoneType' object has no attribute 'set'
>>> 
>>> 
>>> 
>>> does this look like a bug with ironpython? if so, I'll report it to the 
>>> developers, but i need a little more help tracking down exactly what's 
>>> going wrong...
>> 
>> its likely some slightly different behavior in ironpython regarding 
>> descriptors.   If you don't have a lot of SQLA experience, it would be 
>> extremely difficult to get SQLA running with a new Python interpreter.   
>> Getting it to run on Jython took a huge amount of effort and weeks/months of 
>> bughunting, both in SQLA and Jython itself.  We currently don't have any 
>> resources to get it to work on IronPython as well.
>> 
>> 
>>> 
>>> For bonus points:  In the attached database, there's a many-to-many 
>>> relationship between 'movies' and 'directors' via a simple joining table.  
>>> How come SQLA isn't able to figure this out on its own and let me just 
>>> join(movies_table, directors_table)? It seems unneccesary to have to 
>>> specify the extra join(movies_table,md_table).join(directors_table)...
>> 
>> I don't generally open full zipfiled applications, so if you want to attach 
>> a succinct, single-file code example that would help.   If you have 
>> relationships between two classes, the relationship() function is used to 
>> establish that, which would allow query.join(Movie.directors) to generate 
>> the joins automatically.
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To post to this group, send email to sqlalch...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
>> 
>> 
>> 
>> -- 
>> ------------------------------
>> Harry J.W. Percival
>> ------------------------------
>> Italy Mobile: +39 389 095 8959
>> UK Mobile:  +44 (0) 78877 02511 (may be turned off)
>> Skype:         harry.percival
>> Email:          harry.perci...@gmail.com
>> 
>> 
>> 
>> -- 
>> ------------------------------
>> Harry J.W. Percival
>> ------------------------------
>> Italy Mobile: +39 389 095 8959
>> UK Mobile:  +44 (0) 78877 02511 (may be turned off)
>> Skype:         harry.percival
>> Email:          harry.perci...@gmail.com
>> 
>> 
>> 
>> -- 
>> ------------------------------
>> Harry J.W. Percival
>> ------------------------------
>> Italy Mobile: +39 389 095 8959
>> UK Mobile:  +44 (0) 78877 02511
>> Skype:         harry dot percival
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To post to this group, send email to sqlalch...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> 
> 
> -- 
> ------------------------------
> Harry J.W. Percival
> ------------------------------
> Italy Mobile: +39 389 095 8959
> UK Mobile:  +44 (0) 78877 02511
> Skype:         harry dot percival
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to