Hi Masters!

I have a problem with Tutorial wiki2.

When i'm going step by step, everything is OK till i have to edit
scripts/populate.py

„Since we’ve changed our model, we need to make changes to our
populate.py script. In particular, we’ll replace our import of MyModel
with one of Page and we’ll change the very end of the script to create
a Page rather than a MyModel and add it to our DBSession.”

I've changed
from ..models import (
    DBSession,
    Page, # <-here
    Base,
    )

and at the end of a script:
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
    with transaction.manager:
        model = Page(name='newOne', data='whatever') # <--here,
whatever, some text
        DBSession.add(model)

but now
$ ../bin/python setup.py test -q
gives me lots of errors, last line is
AttributeError: 'module' object has no attribute 'views'

and
$ ../bin/populate_tutorial development.ini
2012-01-11 05:41:29,644 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] PRAGMA table_info("pages")
2012-01-11 05:41:29,644 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] ()
2012-01-11 05:41:29,646 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] BEGIN (implicit)
2012-01-11 05:41:29,647 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] INSERT INTO pages (name, data) VALUES (?, ?)
2012-01-11 05:41:29,648 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] ('newOne', '')
2012-01-11 05:41:29,648 INFO  [sqlalchemy.engine.base.Engine]
[MainThread] ROLLBACK
Traceback (most recent call last):
  File "../bin/populate_tutorial", line 8, in <module>
    load_entry_point('tutorial==0.0', 'console_scripts',
'populate_tutorial')()
  File "/home/dziedzic/pyramidtut/tutorial/tutorial/scripts/
populate.py", line 35, in main
    DBSession.add(model)
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_manager.py", line 96, in
__exit__
    self.commit()
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_manager.py", line 89, in
commit
    return self.get().commit()
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_transaction.py", line 342, in
commit
    reraise(t, v, tb)
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_transaction.py", line 333, in
commit
    self._commitResources()
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_transaction.py", line 473, in
_commitResources
    reraise(t, v, tb)
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
transaction-1.2.0-py2.7.egg/transaction/_transaction.py", line 445, in
_commitResources
    rm.tpc_begin(self)
  File "/home/dziedzic/pyramidtut/lib/python2.7/site-packages/
zope.sqlalchemy-0.7-py2.7.egg/zope/sqlalchemy/datamanager.py", line
87, in tpc_begin
    self.session.flush()
  File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/session.py", line
1547, in flush
  File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/session.py", line
1616, in _flush
  File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/unitofwork.py",
line 328, in execute
  File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/unitofwork.py",
line 472, in execute
  File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py", line
2291, in _save_obj
  File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line
1405, in execute
  File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line
1538, in _execute_clauseelement
  File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line
1646, in _execute_context
  File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line
1639, in _execute_context
  File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/default.py",
line 330, in do_execute
sqlalchemy.exc.IntegrityError: (IntegrityError) column name is not
unique u'INSERT INTO pages (name, data) VALUES (?, ?)' ('newOne', '')

All files (__init__.py, models.py and views.py) are copy-pasted from
tutorial, saved and checked twice...
Could somebody help me?

Ł

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to