Following what I've found in the ZODB wiki traveral tutorial (https://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki/index.html), I've installed cookiecutter and did:
cookiecutter gh:Pylons/pyramid-cookiecutter-zodb --checkout 1.9-branch
Then, without done any changes, tried to open a shell on the project:
Got this traceback:
$ pshell development.ini
2017-10-21 08:58:41,941 INFO [chameleon.config:38][MainThread] directory cache: /home/wu/pyramid-zodb-traversal/chameleon.
Traceback (most recent call last):
File "/home/wu/pyramid-zodb-traversal/envs/testapp/bin/pshell", line 11, in <module>
sys.exit(main())
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/pyramid/scripts/pshell.py", line 19, in main
return command.run()
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/pyramid/scripts/pshell.py", line 124, in run
env = self.bootstrap(config_uri, options=config_vars)
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/pyramid/paster.py", line 108, in bootstrap
env = prepare(request)
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/pyramid/scripting.py", line 98, in prepare
root = root_factory(request)
File "/home/wu/pyramid-zodb-traversal/repos/Testapp/testapp/__init__.py", line 14, in root_factory
return appmaker(conn.root())
File "/home/wu/pyramid-zodb-traversal/repos/Testapp/testapp/models/__init__.py", line 18, in appmaker
zodb_root['app_root'] = app_root
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/persistent/mapping.py", line 64, in __setitem__
self._p_changed = 1
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/ZODB/Connection.py", line 835, in register
self._register(obj)
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/ZODB/Connection.py", line 845, in _register
self.transaction_manager.get().join(self)
File "/home/wu/pyramid-zodb-traversal/envs/testapp/lib/python3.6/site-packages/transaction/_manager.py", line 87, in get
raise NoTransaction()
transaction.interfaces.NoTransaction
$
Tried pserve instead:
pserve --reload development.ini
and the app seemed to be "started" right:
$ pserve --reload development.ini
Starting monitor for PID 61548.
2017-10-21 09:03:53,546 INFO [chameleon.config:38][MainThread] directory cache: /home/wu/pyramid-zodb-traversal/chameleon.
Starting server in PID 61548.
Serving on http://localhost:6543
Serving on http://localhost:6543
$
After that, the ZODB database files are there:
$ ls -l Data.*
-rw-r--r-- 1 wu wu 166 Oct 21 09:03 Data.fs
-rw-r--r-- 1 wu wu 9 Oct 21 09:03 Data.fs.index
-rw-r--r-- 1 wu wu 7 Oct 21 09:03 Data.fs.lock
-rw-r--r-- 1 wu wu 106 Oct 21 09:03 Data.fs.tmp
$
(hint, look at the database - Data.fs - size)
After that I tried pshell again and I got the same traceback but, after
started pserve again, I opened http://localhost:6543 in a browser (got there
the pyramid welcome page). Then I looked at the database files again:
$ ls -l Data.*
-rw-r--r-- 1 wu wu 456 Oct 21 09:04 Data.fs
-rw-r--r-- 1 wu wu 31 Oct 21 09:03 Data.fs.index
-rw-r--r-- 1 wu wu 7 Oct 21 09:03 Data.fs.lock
-rw-r--r-- 1 wu wu 258 Oct 21 09:04 Data.fs.tmp
$
and then I did stop pserve and tried pshell:
$ pshell development.ini
2017-10-21 09:04:18,005 INFO [chameleon.config:38][MainThread] directory cache: /home/wu/pyramid-zodb-traversal/chameleon.
Python 3.6.1 (default, Jun 29 2017, 15:42:29)
[GCC 4.2.1 20070719 ] on openbsd6
Type "help" for more information.
Environment:
app The WSGI application.
registry Active Pyramid registry.
request Active request object.
root Root of the default resource tree.
root_factory Default root factory used to create `root`.
>>>
It worked just fine.
So, something is preventing pshell from working on a project that still has no
database (which worked fine in previous versions, as I've been using
pyramid+zodb for years now without this issue)
I was wondering if this could be related to issue #22, which removed some
transaction commits when calling the appmaker code...