werkzeug

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the s...

Context processor using Werkzeug and Jinja2

My application is running on App Engine and is implemented using Werkzeug and Jinja2. I'd like to have something functionally equivalent of Django's own context processor: a callable that takes a request and adds something to the template context. I already have a "context processors" that add something to the template context, but how d...

AJAX upload in Python (WSGI) without Flash/Silverlight, with progress bar

I am looking for a pure Javascript/Python upload example, that uses server polling instead of client-side SWF to display upload progress (like the one on rapidshare.com for example) Currently, website is running on the standalone wsgi server included with Werkzeug framework, but may be moved to mod_wsgi if the load increases. I've trie...

Werkzeug and SQLAlchemy 0.5x session

Updated: Hi all, Going through the Werkzeug link text tutorial, got stack with creating SQLAlchemy session using sessionmaker() instead of create_session() as recommended. Note: it is not about SA, it is about Werkzeug. Werkzeug tutorial: session = scoped_session(lambda: create_session(bind=application.database_engine, autoflush...

Help with Python in the web

I've been using Werkzeug to make WSGI compliant applications. I'm trying to modify the code in the front page. Its basic idea is that you go to the /hello URL and you get a "Hello World!" message. You go to /hello/ and you get "hello !". For example, /hello/jeff yields "Hello Jeff!". Anyway, what I'm trying to do is putting a form in th...

Werkzeug in General, and in Python 3.1

I've been looking really hard at all of the way**(s)** one can develop web applications using Python. For reference, we are using RHEL 64bit, apache, mod_wsgi. History: PHP + MySQL years ago PHP + Python 2.x + MySQL recently and current Python + PostgreSQL working on it We use a great library for communicating between PHP and Pytho...

werkzeug mapping urls to views (via endpoint)

Starting using werkzeug, i try to map urls (from a file urls.py) to views (from a folder views and then in different files to manage differents kinds of view), my folder organisation looks like that : myapp/ - - - application.py - - - urls.py - - - views/ - - - - - - __init__.py - - - - - - common.py - - - - - - places.py - - - - - -...

Getting HTTP GET variables using Tipfy

Hey everyone, I'm currently playing around with tipfy on Google's Appengine and just recently ran into a problem: I can't for the life of me find any documentation on how to use GET variables in my application, I've tried sifting through both tipfy and Werkzeug's documentations with no success. I know that I can use request.form.get('va...

trying to run werkzeug on apache (wsgi error)

My data_site.wsgi file: import main application = application() Error i get at apache: [Thu Apr 29 07:07:41 2010] [error] [client 81.167.201.136] Traceback (most recent call last): [Thu Apr 29 07:07:41 2010] [error] [client 81.167.201.136] File "/var/www/vhosts/data.oddprojects.net/htdocs/data_site.wsgi", line 1, in <module> [Thu A...

Using Python, getting the name of files in a zip archive

Hi, I have several very large zip files available to download on a website. I am using Flask microframework (based on Werkzeug) which uses Python. Is there a way to show the contents of a zip file (i.e. file and folder names) - to someone on a webpage - without actually downloading it? As in doing the working out server side. Assume t...

Flask/Werkzeug, how to return previous page after login

Hi, I am using the Flask micro-framework which is based on Werkzeug, which uses Python. Before each restricted page there is a decorator to ensure the user is logged in, currently returning them to the login page if they are not logged in, like so: # Decorator def logged_in(f): @wraps(f) def decorated_function(*args, **kwargs)...

Redirecting an old URL to a new one with Flask micro-framework

Hi, I'm making a new website to replace a current one, using Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). The core functionality and many pages are the same. However by using Flask many of the previous URLs are different to the old ones. I need a way to somehow store the each of the old URLs and the ne...

How to understand this code of flask?

Could anyone explain this line? g = LocalProxy(lambda: _request_ctx_stack.top.g) code from flask from werkzeug import LocalStack, LocalProxy # context locals _request_ctx_stack = LocalStack() current_app = LocalProxy(lambda: _request_ctx_stack.top.app) request = LocalProxy(lambda: _request_ctx_stack.top.request) session = LocalProx...

Flask/Werkzeug how to attach HTTP content-length header to file download

Hi, I am using Flask (based on Werkzeug) which uses Python. So the user can download a file, I'm using the send_from_directory function: http://flask.pocoo.org/docs/api/?highlight=send_from_directory#flask.send_from_directory However when actually downloading the file, the HTTP header content-length is not set. So the user has no idea...

URL Builder for CherryPy

After using werkzeug as a web framework (which is great and simple, but doesnt support some features), i'm now trying cherrypy. Now what I miss in cherrypy is werkzeug's elegant way of building urls (e.g. for links in templates) using the name of a decorated function like this: @expose('/archive/<int:year>/<int:month>') def archive(req...

Catch-all routing using Tipfy

Using tipfy, how does one express a catch-all route in urls.py if more specific routes do not match? Tipfy uses Werkzeug-like routing, so there's this (in urls.py): def get_rules(app): rules = [ Rule('/<any>', endpoint='any', handler='apps.main.handlers.MainHandler'), Rule('/', endpoint='main', handler='apps.main.handlers.Ma...