| WebSeitz/wikilog |
| Python Paste |
|
| last edited by BillSeitz on Jul 1, 2008 8:36 pm |
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 J Eby 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
Apr'2006
Python Paste coming from Python On Mac
[Paste Deploy]: got good results from running sudo easy_install PasteDeploy
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 Python Paste.
Since Python Paste 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 WareWeb 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:
PasteScript#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
Copying setup.cfg to ./flux/setup.cfg
Copying setup.py_tmpl to ./flux/setup.py
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/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:
PasteScript#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
Copying setup.cfg to ./flux/setup.cfg
Copying setup.py_tmpl to ./flux/setup.py
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/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:
PasteScript#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
Copying setup.cfg to ./flux/setup.cfg
Copying setup.py_tmpl to ./flux/setup.py
Running /Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/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* ./PasteDeploy-0.5-py2.4.egg/paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl ./PasteDeploy-1.1-py2.4.egg/paste/deploy/paster_templates/paste_deploy/docs/devel_config.ini_tmpl ./RhubarbTart-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('PasteScript==0.5.2dev-r5241', 'paster')
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
self.require(requires)[0].run_script(script_name, ns)
(***** snip many lines******)
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
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: WSGIUtils
I see the wrong version of paster is running.
Go remove all the old directories in site_packages, try again:
paster serve docs/devel_config.ini
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/Current/bin/paster", line 4, in ?
import pkg_resources
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 ?
for dist in working_set.resolve(
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
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: PasteScript==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:
cd /Library/Frameworks/Python.framework/Versions/Current/bin
ls gives 289 20 May 2006 paster
head paster
#!/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python
# EASY-INSTALL-SCRIPT: 'PasteScript==0.5.2dev-r5241','paster'
__requires__ = 'PasteScript==0.5.2dev-r5241'
import pkg_resources
pkg_resources.run_script('PasteScript==0.5.2dev-r5241', 'paster')
Yes, I used to have a directory PasteScript-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:
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('PasteScript==1.1', 'paster')
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
self.require(requires)[0].run_script(script_name, ns)
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
execfile(script_filename, namespace, namespace)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PasteScript-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/PasteScript-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/PasteScript-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/PasteScript-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/PasteScript-1.1-py2.4.egg/paste/script/serve.py", line 192, in command
relative_to=base, global_conf=vars)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PasteScript-1.1-py2.4.egg/paste/script/serve.py", line 212, in loadserver
relative_to=relative_to, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 568, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 1829, in load
if require: self.require(env, installer)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 1842, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
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
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: WSGIUtils
Feb09
realize I have a [W S G I Utils]-0.7 zipped file on my desktop. Unzip, copy to /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/[W S G I Utils]
tried launching again, same error
duh, [W S G I Utils] uses Easy Install, 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('PasteScript==1.1', 'paster')
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
self.require(requires)[0].run_script(script_name, ns)
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
execfile(script_filename, namespace, namespace)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PasteScript-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/PasteScript-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/PasteScript-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/PasteScript-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/PasteScript-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/PasteScript-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-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/PasteDeploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 562, in find_egg_entry_point
pkg_resources.require(self.spec)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 585, in require
needed = self.resolve(parse_requirements(requirements))
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 464, in resolve
requirements = list(requirements)[::-1] # set up the stack
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/setuptools-0.6a11-py2.4.egg/pkg_resources.py", line 2259, in parse_requirements
raise ValueError("Missing distribution spec", line)
ValueError: ('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.
he was right, it was in that devel_config.ini file that I copied from elsewhere because I could get it auto-generated.
Feb18'2007
modified devel_config.ini to have use = egg:flux
now get:
Traceback:
(lots snipped)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PasteDeploy-1.1-py2.4.egg/paste/deploy/loadwsgi.py", line 573, in find_egg_entry_point
raise LookupError(
LookupError: 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: )
do I edit entry_points.txt or something else?
Later play with Ro Baccia.
| User Options Recent Changes Help Page |