[Pypi-checkins] r746 - branches/tarek-pep-345-support

tarek.ziade python-checkins at python.org
Wed Mar 17 03:27:38 CET 2010


Author: tarek.ziade
Date: Wed Mar 17 03:27:38 2010
New Revision: 746

Modified:
   branches/tarek-pep-345-support/README
   branches/tarek-pep-345-support/pypi.wsgi
Log:
make it simple to run pypi.wsgi, using wsgiref, and added more detail in README

Modified: branches/tarek-pep-345-support/README
==============================================================================
--- branches/tarek-pep-345-support/README	(original)
+++ branches/tarek-pep-345-support/README	Wed Mar 17 03:27:38 2010
@@ -1,7 +1,7 @@
 Required packages
 -----------------
 
-To run the PyPI software, you need PostgreSQL, and all 
+To run the PyPI software, you need PostgreSQL, and all
 these packages located at PyPI:
 
 - cElementTree
@@ -10,13 +10,34 @@
 - zope.tal
 - zope.tales
 - zope.i18nmessageid
-- psycopg2 
+- psycopg2
 - M2Crypto
 - BeautifulSoup
+- docutils
 
-You can create a development environment like this, if you
-have virtualenv installed::
+Quick development setup
+-----------------------
+
+Make sure you read http://wiki.python.org/moin/CheeseShopDev#DevelopmentEnvironmentHints
+and you have a working PostgreSQL DB.
+
+Make sure your config.ini is up-to-date. Change CONFIG_FILE at the begining
+of pypi.wsgi, so it looks like this::
+
+    CONFIG_FILE = 'config.ini'
+
+Then, you can create a development environment like this, if you have
+virtualenv installed::
 
     $ virtualenv --no-site-packages --distribute .
-    $ bin/easy_install cElementTree zope.interface zope.pagetemplate zope.tal zope.tales zope.i18nmessageid psycopg2 M2Crypto BeautifulSoup
+    $ bin/easy_install cElementTree zope.interface zope.pagetemplate
+    $ bin/easy_install zope.tal zope.tales zope.i18nmessageid psycopg2
+    $ bin/easy_install  M2Crypto BeautifulSoup docutils
+
+Then you can launch the server using the pypi.wsgi script::
+
+    $ bin/python pypi.wsgi
+    Serving on port 8000...
+
+PyPI will be available in your browser at http://localhost:8000
 

Modified: branches/tarek-pep-345-support/pypi.wsgi
==============================================================================
--- branches/tarek-pep-345-support/pypi.wsgi	(original)
+++ branches/tarek-pep-345-support/pypi.wsgi	Wed Mar 17 03:27:38 2010
@@ -6,18 +6,21 @@
 
 store.keep_conn = True
 
+CONFIG_FILE = '/data/pypi/config.ini'
+
 class Request:
 
     def __init__(self, environ, start_response):
         self.start_response = start_response
-        self.rfile = cStringIO.StringIO(environ['wsgi.input'].read())
+        length = int(environ['CONTENT_LENGTH'])
+        self.rfile = cStringIO.StringIO(environ['wsgi.input'].read(length))
         self.wfile = cStringIO.StringIO()
-        self.config = config.Config('/data/pypi/config.ini')
-    
+        self.config = config.Config(CONFIG_FILE )
+
     def send_response(self, code, message='no details available'):
         self.status = '%s %s' % (code, message)
         self.headers = []
-        
+
     def send_header(self, keyword, value):
         self.headers.append((keyword, value))
 
@@ -47,3 +50,11 @@
     r = Request(environ, start_response)
     webui.WebUI(r, environ).run()
     return [r.wfile.getvalue()]
+
+if __name__ == '__main__':
+    # very simple wsgi server so we can play locally
+    from wsgiref.simple_server import make_server
+    httpd = make_server('', 8000, application)
+    print "Serving on port 8000..."
+    httpd.serve_forever()
+


More information about the Pypi-checkins mailing list