Comments (5)
As suggested in Pylons/pyramid#3137 removing this line:
settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
from the main function in init.py in the root of the app makes pshell to work as expected before the database files are created.
Another workaround, change the root_factory method in init.py to be something like this:
def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root(), request.tm)
and appmaker:
def appmaker(zodb_root, tm):
if 'app_root' not in zodb_root:
app_root = MyModel()
zodb_root['app_root'] = app_root
tm.commit()
return zodb_root['app_root']
So the transaction is commited propertly
from pyramid-cookiecutter-zodb.
If you're still suggesting to use the pyramid_tm.explicit_manager
then this fix will not work adequately because a commit in the middle of a request will not open a new transaction for later work. Performing a commit in the middle will break things that would have worked or sort-of-worked previously across implicitly-created transactions. At the very least a tm.begin()
is required after the commit, but that is not really a good fix either.
from pyramid-cookiecutter-zodb.
Not really suggesting a fix (yet), it was more like trying to find out what is causing this and what a proper fix could be.
This code is run once, the first time you start the app, as the database has to be created... so I was wondering how much breakage adding a transaction commit there could cause (even if, after the commit, you have to explicitly start a new transaction as you mentioned in your comment)
In previous versions of pyramid, the zodb was created after pshell/pserve/etc finished starting the app, not after the first request finished (which is what is happening now)
Maybe the fix should be made somewhere else, outside appmaker(), ensuring a transaction commit is done once the app has been fully initialized?
from pyramid-cookiecutter-zodb.
The alchemy cookiecutter has a manual step to create the database that uses a script initialize.db
. Can that pattern be repeated with ZODB in this cookiecutter?
from pyramid-cookiecutter-zodb.
fixed by #35
from pyramid-cookiecutter-zodb.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyramid-cookiecutter-zodb.