[PYTHON] pyramid tutorial memo (bank account)

Pyramid Tutorial — Pyramid Tutorial for PyCon JP Sprint 1.0 documentation Make a note of the points you were addicted to with reference to.


What kind of screen can be created

bankbalance.png


No HTTP Found

Add the following to the beginning of views.py

python


from pyramid.httpexceptions import HTTPFound

Import error in interpreter

Let's work with the defined BankAccount model in the interpreter.

python


>>> from bankaccount import models

If you can't import around zope.sqlalchemy, you're probably doing it from the python prompt. I think that the import error will disappear below.

python


pshell development.ini

Initialize the bankaccount.db file

I overlooked what to do when I came here.

python


>>> from bankaccount import models
>>> models.Base.metadata.create_all()
>>> b = models.BankAccount(name=u'default')
>>> models.DBSession.add(b)
>>> import transaction
>>> transaction.commit()

index.mak file not found

There is a way to pass the templates folder to the beginning of the tutorial, so use it.

file organization

File Description
development.ini db definition, debugtoolbar display settings
bankaccount.db real db file
bankaccount/init.py route setting, path specification of mako template
bankaccount/views.py controller
bankaccount/models.py db table definition and model
bankaccount/resources.py Get the balance
bankaccount/templates/index.mak Balance display, deposit, withdrawal

download

bankaccount

Recommended Posts

pyramid tutorial memo (bank account)
django tutorial memo
Python OpenCV tutorial memo
FastAPI Tutorial Memo Part 1
pyramid tutorial notes (single_file_tasks)
FastAPI Tutorial Memo Part 3 Query Parameters
FastAPI Tutorial Memo Part 2 Path Parameters