I am not sure if this is just a SQLAlchemy problem  I am having or if
it is with one specifically within the context of TurboGears.

Before I get started, here is what I am using:
TurboGears 1.0.4b3
Elixir 0.5
SQLAlchemy 0.4.1

I know I am doing _something_ wrong but can't find a clue through
googling.

Here are the applicable classes in model.py:  (Note that this is the
most 'complex'  entry, but in fact any data entered like just a
description, ends up with the same results.)
class User(Entity):
    """
    Reasonably basic User definition.
    Probably would want additional attributes.
    """
    using_options(tablename='te_user')

    user_id = Field(Integer, primary_key=True)
    user_name = Field(Unicode(16), unique=True)
    email_address = Field(Unicode(255), unique=True)
    display_name = Field(Unicode(255))
    password = Field(Unicode(40))
    created = Field(DateTime, default=datetime.now)
    groups = ManyToMany('Group', tablename='user_group')

    @property
    def permissions(self):
        perms = set()
        for g in self.groups:
            perms |= set(g.permissions)
        return perms

class Script(Entity):
    """
    Container and identifier for the lowest building block of test,
the
    scriptlets that run specific operations.
    """
    using_options(tablename='script')

    script_id = Field(Integer, primary_key=True)
    script_title = Field(Unicode(70))
    description = Field(Unicode(255))
    script_path = Field(Unicode)
    created_dt = Field(DateTime, default=datetime.now)
    updated_dt = Field(DateTime, default=datetime.now)
    active = Field(Boolean)
    # foreign key fields
    created_id = ManyToOne('User')
    updated_id = ManyToOne('User')

>From the tg app or from the shell, when I perform the following steps
and receive the Traceback that follows those steps.
>>> user = User.query.one()
>>> script = Script(description='Test Script 1', created_id=user, 
>>> updated_id=user)
>>> session.flush()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
scoping.py", line 74, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
session.py", line 683, in flush
    self.uow.flush(self, objects)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 209, in flush
    flush_context.execute()
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 436, in execute
    UOWExecutor().execute(self, head)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1074, in execute_save_steps
    self.execute_childtasks(trans, task, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1092, in execute_childtasks
    self.execute(trans, child, isdelete)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1074, in execute_save_steps
    self.execute_childtasks(trans, task, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1092, in execute_childtasks
    self.execute(trans, child, isdelete)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1074, in execute_save_steps
    self.execute_childtasks(trans, task, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1092, in execute_childtasks
    self.execute(trans, child, isdelete)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1074, in execute_save_steps
    self.execute_childtasks(trans, task, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1092, in execute_childtasks
    self.execute(trans, child, isdelete)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1074, in execute_save_steps
    self.execute_childtasks(trans, task, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1092, in execute_childtasks
    self.execute(trans, child, isdelete)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1055, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1069, in execute_save_steps
    self.save_objects(trans, task)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
unitofwork.py", line 1060, in save_objects
    task.mapper.save_obj(task.polymorphic_tosave_objects, trans)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
mapper.py", line 1077, in save_obj
    value = mapper.get_attr_by_column(obj, col, False)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
mapper.py", line 926, in get_attr_by_column
    return prop.getattr(obj, column)
  File "c:\python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg
\sqlalchemy\orm\
properties.py", line 56, in getattr
    return getattr(object, self.key)
AttributeError: 'ColumnProperty' object has no attribute 'key'


So what am I doing wrong with my schema declarations?

Thanks,
Jason
--~--~---------~--~----~------------~-------~--~----~
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