Never mind, I found my ( stupid! ) error by diffing with Lee's wonderful
simple blog tutorial. Thanks again Lee! ( I left out "Integer".
Unfortunately the error messages are not so useful for backtracking on
that one! )

Iain

On Thu, 2007-25-01 at 13:58 -0800, iain duncan wrote:
> Hi folks, I'm trying to set up SA with MySQL but can't get foreign key
> relations working properly. Below is the result of the "tg-admin sql
> create" and my model. If anyone can shed some light that would be great,
> gooling the error message turned up nothing. I have had no problems
> until turning on the foreign key. 
> 
> 2007-01-25 13:53:39,941 sqlalchemy.pool.QueuePool.0x..14 INFO Connection
> <_mysql.connection open to 'localhost' at 863e0ac> being returned to
> pool
> Traceback (most recent call last):
>   File "/usr/local/bin/tg-admin", line 7, in ?
>     sys.exit(
>   File
> "/usr/lib/python2.4/site-packages/TurboGears-1.0-py2.4.egg/turbogears/command/base.py",
>  line 389, in main
>     command.run()
>   File
> "/usr/lib/python2.4/site-packages/TurboGears-1.0-py2.4.egg/turbogears/command/base.py",
>  line 115, in run
>     sacommand(command, sys.argv)
>   File "<string>", line 5, in sacommand
>   File
> "/usr/lib/python2.4/site-packages/TurboGears-1.0-py2.4.egg/turbogears/command/base.py",
>  line 70, in sacreate
>     metadata.create_all()
>   File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 862, in
> create_all
>   File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 413,
> in create
>   File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 437,
> in _run_visitor
>   File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 882, in
> accept_schema_visitor
>   File "build/bdist.linux-i686/egg/sqlalchemy/ansisql.py", line 637, in
> visit_metadata
>   File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 268, in
> accept_schema_visitor
>   File "build/bdist.linux-i686/egg/sqlalchemy/ansisql.py", line 658, in
> visit_table
>   File "build/bdist.linux-i686/egg/sqlalchemy/databases/mysql.py", line
> 435, in get_column_specification
> AttributeError: 'ForeignKey' object has no attribute 'engine_impl'
> 
> 
> Here is the model in question:
> # A web page within the site
> page_table = Table("pages", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("name", Unicode(100)),
>     Column("title", Unicode(100)),
>     Column("link", Unicode(50)),            
>     Column("content", Unicode),
>     Column("notes", Unicode),
>     Column("visible", Boolean, default=True),
> )
> 
> # menu items
> menu_table = Table("menu_items", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("name", Unicode(100) ),
>     Column("page_id", ForeignKey("pages.id"), nullable=False ),
>     Column("title", Unicode(100) ),
>     Column("link", Unicode(100) ),
>     Column("ordering", Integer, default=0 ), 
>     Column("notes", Unicode),
>     Column("visible", Boolean, default=True),
> )    
> 
> class Page(object):
>     pass
> class Menu_Item(object):
>     pass
> 
> assign_mapper(session.context, Page, page_table)
> assign_mapper(session.context, Menu_Item, menu_table,
>     properties = { "page": relation(Page) } )
> 
> 
> Thanks,
> Iain
> 
> 
> 
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to