Pyramid For Simplest Thing

After trying Django For Simplest Thing, decide to try using Pyramid for Simplest Thing instead...

starting Apr19'2012

Using VirtualEnv I'd installed for Django.

Install Pyramid with pip, do a freeze.

  • (first renamed old requirements.txt to requirements_dj.txt, and piped this new freeze to requirements_pyr.txt)
  • hrm, the new requirements_pyr.txt file includes Django bits.

Do Hello World app to make sure things are really running. Done.

Create scaffold for project (Apr23): go into st (VirtualEnv) directory, do bin/pcreate -s alchemy ../pyramid/mf So it will use SqlAlchemy for persistence. (Hopefully can talk through that with straight SQL commands rather than ORM.)

  • I think their standard approach puts the project directory inside the st, and not doing it that way may be creating a mess below...

Run tests from same place (Apr25): bin/python ../pyramid/mf/setup.py test -q and it did a bunch of egg installs.

Run app bin/pserve ../pyramid/mf/development.ini get error pkg_resources.DistributionNotFound: waitress - could this be because I put project in wrong directory?

  • no I needed to do a fresh pip install of waitress.
  • run pserve again: error pkg_resources.DistributionNotFound: mf

Decide that directory structure was a mistake. Remove the pyramid/mf directory.

Repeat starting process

  • bin/pcreate -s alchemy mf
  • cd mf; ../bin/python setup.py develop - argh http://pygments.org is down! OK, now back up.
  • ../bin/python setup.py test -q all good.
  • ../bin/pserve development.ini all good
  • hit http://0.0.0.0:6543 get error about SqlAlchemy needing setup

Copy SQLite mf.db created by Django into local directory, restart, hit url again. Get SqlAlchemy error message again. Querying models table. Obviously I'm going to have to build a db from scratch, then if I'm lucky maybe I can import data from the Django db.

Hmm, this raises some issues:

  • how does user authentication work?
    • the core bits of Pyramid documentation on authentication don't stores users in a table, which makes me nervous
    • this looks promising, and gives models (since I'll need a users table either way as part of my system)
  • hmm, does Pyramid or SqlAlchemy automatically generate SQL from the models.py file? I assume so, but need to confirm. And is there a migration tool?
    • yes it does, and yes there's a SqlAlchemy-migrate tool
  • and when I get to certain things can I write SQL expressions directly, rather than using the ORM? Gloria W said yes, but I need to find some docs.

Install nose, etc. (Apr26)

Make models file: start by copy/paste from Django For Simplest Thing models.py then start tweaking from Pyramid examples.

  • just set up User model. Realize I don't know the basics of working with this stuff.

Install the shootout demo app. (Apr27)

  • recognize that initialize_shootout_db is mapped in entry_points.txt to scripts.initializedb, and when you run that script it uses your models.py to talk to your SQL engine.
  • change development.ini to adjust port number so can run mf and shootout at the same time
  • make some tweaks to mf/models.py to match the shootout version, finally able to run pserve and have it come up. Hitting the URL gives generic Pyramid splash page.
  • Enter a couple bits of data so that the template has something to render.
  • Start copying bits to mf to modify and see if they work.
  • Ugh, Template System is TAL from Zope! Me cry now...
  • End up with error triggered by template metal:use-macro="base" so go back to actually read some docs about macros in templates.
    • hrm, no file in shootout uses define-macro, so maybe it just automatically uses base.pt - but I copied that file too...
    • this doc looks appropriate (May04)...
      • add couple subscribers lines to __init__.py
      • copy subscribers.py from shootout
      • cool on go the next bug!
    • have to create consistency with lots of shootout stuff I copied...
  • Now renders a page at /users but is rather unreadable because I purposely pointed to the default pylons.css instead of shootout's CSS file.

Just to keep things ridiculous, playing with WebpyForSimplest Thing.


Edited:    |       |    Search Twitter for discussion