Python Paste brings consistency to Python web development and web application installation, providing tools for both developers and system administrators.
a Python Web Framework built on top of WSGI?
Phillip JEby seems to have some issues with its implicit focus
by Ian Bicking
context/framing
Oct'2006 http://blog.ianbicking.org/paste-1-0.html as part of v1.0 announcement
http://blog.ianbicking.org/its-not-another-damn-framework.html
URI parsing/dispatching http://pythonpaste.org/url-parsing-with-wsgi.html
<hr>
Apr'2006
PythonPaste coming from Python On Mac
Paste Deploy: got good results from running 'sudo easy_install Paste Deploy'
Paste Script: 'sudo easy_install Paste Script'
- Once, installed, '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste-0.5-py2.4.egg' is a directory.
Going into 'paste' subdirectory and running 'python httpserver.py' launches a Web Server on port 8888.
actually using it with Rhubarb Tart
Oct'2006
Dropping Rhubarb Tart, just trying Select Or with PythonPaste.
Since PythonPaste has gone v1, I'll upgrade. Since it uses Easy Install, that's easy::
- easy_install --upgrade Paste
Searching for Paste Reading http://www.python.org/pypi/Paste/ Reading http://pythonpaste.org Best match: Paste 1.0 Downloading http://cheeseshop.python.org/packages/2.4/P/Paste/Paste-1.0-py2.4.egg#md5=33775bbab4aa873ed691323d99893ecb Processing Paste-1.0-py2.4.egg creating /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste-1.0-py2.4.egg Extracting Paste-1.0-py2.4.egg to /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages Removing Paste 0.5 from easy-install.pth file Adding Paste 1.0 to easy-install.pth file Installed /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste-1.0-py2.4.egg Processing dependencies for Paste
You create a new app with 'paster create' (you can have different Templates). There are 2 sample apps: a To Do List that uses a Data Base back-end, and a File Browser (which uses Ware Web and a number of other libraries).
I tried a 'create' without naming a template at all::
- ~/Documents/flux billseitz$ paster create flux
Selected and implied templates:
Paste Script#basic_package A basic setuptools-enabled package
Variables:
- package: flux project: flux
Creating template basic_package Enter version (Version (like 0.1)) ['']: 0.1 (snip) Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]: Creating directory ./flux
- Recursing into +package+
- Creating ./flux/flux/
Copying init.py to ./flux/flux/init.py
- Creating ./flux/flux/
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/Mac OS/Python setup.py egg_info
An app includes directories: (app-name), docs, and tests, plus a setup.py file. I think it also includes a setup.cfg file and an '(app-name).egg-info' directory.
Here's some explanation of writing Hello World, but it doesn't tie into the app just created. Would you put this code into 'init.py'?
so I tried putting the code there, then went into that directory and ran 'python init.py' and then pointed browser at http://localhost:8080/ and it worked.
Things seemed odd, so I tried again specifying 'basic_template'::
- ~/Documents/flux billseitz$ paster create flux template=basic_package
Selected and implied templates:
Paste Script#basic_package A basic setuptools-enabled package
Variables:
- package: flux project: flux template: basic_package
Creating template basic_package Enter version (Version (like 0.1)) ['']: 0.1 (snip) Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]: Creating directory ./flux
- Recursing into +package+
- Creating ./flux/flux/
Copying init.py to ./flux/flux/init.py
- Creating ./flux/flux/
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/Mac OS/Python setup.py egg_info
This didn't seem to make much of a difference. Neither approach gives you a 'docs' subfolder with 'example_config.ini' or 'devel_config.ini' files (the latter seems to be where you do URI-mapping a-la Select Or).
- this page notes it's creation, but that's from the file-browser sample app which uses multiple non-basic templates, so it's not clear to me where this comes from. Posted question to list.
Ian Bicking says I believe the paste_deploy template creates an ini file - basic_template potentially applies to non-web Python packages.
So try that::
- ~/Documents/flux billseitz$ paster create flux template=paste_deploy
Selected and implied templates:
Paste Script#basic_package A basic setuptools-enabled package
Variables:
- package: flux project: flux template: paste_deploy
Creating template basic_package Enter version (Version (like 0.1)) ['']: 0.1 (snip) Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]: Creating directory ./flux
- Recursing into +package+
- Creating ./flux/flux/
Copying init.py to ./flux/flux/init.py
- Creating ./flux/flux/
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/Mac OS/Python setup.py egg_info
That didn't do it either.
Jan20'2007 - upgrade all the packages (hadn't done that before), tried again. Still no success.
Even try using 'template="paste_deploy"' but that doesn't work either.
Maybe I'll just create the docs directory/files by hand, or check out the ones that are in the sample folder and copy them...::
find . -name devel_conf
./Paste Deploy-0.5-py2.4.egg/paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl ./Paste Deploy-1.1-py2.4.egg/paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl ./Rhubarb Tart-0.6dev_r5247-py2.4.egg/rhubarbtart/paste_templates/rhubarbtart/docs/devel_config.ini_tmpl
That worked, though filename ends in .ini_templ - but I just rip off the ending bit.
Try launching::
- ~/Documents/flux/flux billseitz$ paster serve docs/devel_config.ini
Traceback (most recent call last):
- File "/Library/Frameworks/Python.framework/Versions/Current/bin/paster", line 5, in ?
pkg_resources.run_script('Paste Script==0.5.2dev-r5241', 'paster')
- self.require(requires)[0].run_script(script_name, ns)
( snip many lines) raise Distribution Not Found(req) # XXX put more info here pkg_resources.Distribution Not Found: WSGIUtils I see the wrong version of paster is running. Go remove all the old directories in site_packages, try again:: Traceback (most recent call last): raise Distribution Not Found(req) # XXX put more info here pkg_resources.Distribution Not Found: Paste Script==0.5.2dev-r5241 Ugh, I suspect I should have deleted via Setup Tools rather than doing it directly. Or maybe it's that paster hasn't been updated:: ls gives 289 20 May 2006 paster head paster #!/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/Mac OS/Python # EASY-INSTALL-SCRIPT: 'Paste Script==0.5.2dev-r5241','paster' requires = 'Paste Script==0.5.2dev-r5241' import pkg_resources pkg_resources.run_script('Paste Script==0.5.2dev-r5241', 'paster') Yes, I used to have a directory 'Paste Script-0.5.2dev_r5241-py2.4.egg' Do I need to upgrade that separately from Paste Script and Paste Deploy? I thought paster was part of Python Script... So I'm going to edit that little paster file by hand... Then try launching again:: Traceback (most recent call last): pkg_resources.run_script('Paste Script==1.1', 'paster') File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/EGG-INFO/scripts/paster", line 18, in ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 76, in run File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 115, in invoke File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 210, in run File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/serve.py", line 192, in command File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/serve.py", line 212, in loadserver relative_to=relative_to,
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 2441, in ?
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 483, in resolve
kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 407, in run_script
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 1084, in run_script
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 199, in loadserver
return loadobj(SERVER, uri, name=name, kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 213, in loadobj
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 237, in loadcontext
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 267, in _loadconfig
- return loader.get_context(object_type, name, global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 393, in get_context
- section)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 414, in _context_from_use
- context = self.get_context(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 345, in get_context
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 237, in loadcontext
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 274, in _loadegg
- return loader.get_context(object_type, name, global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 541, in get_context
- entry_point, protocol, ep_name = self.find_egg_entry_point(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 568, in find_egg_entry_point
- possible.append((entry.load(), protocol, entry.name))
- if require: self.require(env, installer)
- working_set.resolve(self.dist.requires(self.extras),env,installer))
raise Distribution Not Found(req) # XXX put more info here
pkg_resources.Distribution Not Found: WSGIUtils
Feb09
realize I have a WSGIUtils-0.7 zipped file on my desktop. Unzip, copy to /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/WSGIUtils
- tried launching again, same error
- * duh, WSGIUtils uses EasyInstall, so I do that
- sudo easy_install wsgiutils
Password: Searching for wsgiutils Reading http://www.python.org/pypi/wsgiutils/ Couldn't find index page for 'wsgiutils' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://www.python.org/pypi/ Reading http://www.python.org/pypi/WSGIUtils/0.7 Reading http://www.owlfish.com/software/wsgiutils/index.html Best match: WSGIUtils 0.7 Downloading http://cheeseshop.python.org/packages/2.4/W/WSGIUtils/WSGIUtils-0.7-py2.4.egg#md5=828542ebebc0f72d006b931fdfeb216f Processing WSGIUtils-0.7-py2.4.egg Moving WSGIUtils-0.7-py2.4.egg to /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages Adding WSGIUtils 0.7 to easy-install.pth file Installed /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/WSGIUtils-0.7-py2.4.egg Processing dependencies for wsgiutils
- * try launch, get different error
- Traceback (most recent call last):
- File "/Library/Frameworks/Python.framework/Versions/Current/bin/paster", line 5, in ?
pkg_resources.run_script('Paste Script==1.1', 'paster')
- self.require(requires)[0].run_script(script_name, ns)
- execfile(script_filename, namespace, namespace)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/EGG-INFO/scripts/paster", line 18, in ?
- command.run()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 76, in run
- invoke(command, command_name, options, args[1:])
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 115, in invoke
- exit_code = runner.run(args)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/command.py", line 210, in run
- result = self.command()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/serve.py", line 194, in command
- relative_to=base, global_conf=vars)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Script-1.1-py2.4.egg/paste/script/serve.py", line 215, in loadapp
- return loadapp(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 193, in loadapp
return loadobj(APP, uri, name=name, kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 213, in loadobj
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 237, in loadcontext
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 267, in _loadconfig
- return loader.get_context(object_type, name, global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 384, in get_context
- global_additions=global_additions)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 454, in _filter_app_context
- context.next_context = self.get_context(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 393, in get_context
- section)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 414, in _context_from_use
- context = self.get_context(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 345, in get_context
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 237, in loadcontext
- global_conf=global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 274, in _loadegg
- return loader.get_context(object_type, name, global_conf)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 541, in get_context
- entry_point, protocol, ep_name = self.find_egg_entry_point(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 562, in find_egg_entry_point
- pkg_resources.require(self.spec)
- needed = self.resolve(parse_requirements(requirements))
- requirements = list(requirements)[::-1] # set up the stack
raise Value Error("Missing distribution spec", line)
- File "/Library/Frameworks/Python.framework/Versions/Current/bin/paster", line 5, in ?
Value Error: ('Missing distribution spec', '${project}')
I posted on the email list, and Ian responded: You probably have something like "use = egg:${project}" in a config file. Feb18'2007 modified devel_config.ini to have (lots snipped) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Paste Deploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 573, in find_egg_entry_point raise Lookup Error( Lookup Error: Entry point 'main' not found in egg 'flux' (dir: /Users/billseitz/Documents/flux/flux; protocols: paste.app_factory, paste.composite_factory, paste.composit_factory; entry_points: ) Later play with Ro Baccia.
use = egg:flux