cherrypy

CherryPy configuration tools.staticdir.root problem

Hi there, How can I make my static-file root directories relative to my application root folder (instead of a hard-coded path)? In accordance with CP instructions (http://www.cherrypy.org/wiki/StaticContent) I have tried the following in my configuration file: tree.cpapp = cherrypy.Application(cpapp.Root()) tools.staticdir.root = cpap...

More efficient web framework than Web.py? Extremely Pythonic please!

I love webpy, it's really quite Pythonic but I don't like having to add the url mappings and create a class, typically with just 1 function inside it. I'm interested in minimising code typing and prototyping fast. Does anyone have any up and coming suggestions such as Bobo, Nagare, Bottle, Flask, Denied, cherrypy for a lover of webpy's ...

CherryPy configuration for CSS file access

The following is the result of CherryPy and css pathing problems I have recently posted, both of which have been answered, but another problem has arisen. I have a html page which I preview in a browser (via. editor/IDE) and which calls a css file from a css folder in parallel with my application folder (containing main.py and My.html f...

Launching browser within CherryPy

I have a html page displayed using... cherrypy.quickstart(ShowHTML(htmlfile), config=configfile) Once the page is loaded (eg. initiated via. the command 'python mypage.py'), I would like to automatically launch the browser to display the page (eg. via. http://localhost/8000). Is there any way I can achieve this (eg. via. a hook withi...

cherrypy when to know that the server has started

I am trying to write some unit tests for a small web service written with Cherrypy and I am wondering what's the best way to figure out that the server has started, so i don't get connection refused if I try to connect too early to the service ? ...

How to return an image in an HTTP response with CherryPy

I have code which generates a Cairo ImageSurface, and I expose it like so: def preview(...): surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) ... cherrypy.response.headers['Content-Type'] = "image/png" return surface.get_data() preview.exposed = True This doesn't work (browsers report that the image has...

Ajax calls to subdomain

I have one server located at example.com running apache, serving my static html files. I also have a json service located at api.example.com running python with cherrypy. The user requests example.com and get the index html page. On that page I make an ajax request with jquery to the json service. document.domain returns example.com ...

Is it possible to debug CherryPy applications?

Hey All, I've seen this question posted here before but I want to get a final yes/no on this. I've been trying to debug my app using Netbeans 6.8 (no luck at all) and the newly released Netbeans 6.9 (notices that code has been called but fails to stop the code from executing). Is it possible to debug CherryPy applications? ...

Cherrypy multithreading example

I do know that cherrypy is a multithreaded and also has a threadpool implementation. So I wanted to try an example showing multithreaded behaviour. Now lets say I've my some function in the root class and rest all things are configured def testPage(self, *args, **kwargs): current = threading.currentThread() print 'Starting ' , c...

Memory not released by python cherrypy application on linux

I have a long running process that will fetch 100k rows from the db genrate a web page and then release all the small objets (list, tuples and dicts). On windows, after each request the memory is freed. Howerver, on linux, the memory of the server keeps growing. The following posts describes what the problem is and one possible solution...

Writing a CherryPy Decorator for Authorization

I have a cherrypy application and on some of the views I want to start only allowing certain users to view them, and sending anyone else to an authorization required page. Is there a way I can do this with a custom decorator? I think that would be the most elegant option. Here's a basic example of what I want to do: class MyApp: ...

Class not refreshing on 2nd url call

Hi there, I have a web page with a link to a url eg./customer/showitem?id=7, which displays details of a specific customer in a child-window using method showitem() in class customer. The method may set the value of a customer class attribute that controls an alert which is displayed when the page is loaded (eg. self.onloadalert="Warni...

Mako Templates : How to find the name of the template which the current template is included by ?

Hi. I have multiple templates that include each other, such as : t1.html : ... <%include file="t2.html" args="docTitle='blablabla'" /> ... t2.html: <%page args="docTitle='Undefined'"/> <title>${docTitle}</title> ... And what I want to do is to determine that t2 is included by t1 (or another one, so I can use its name). No specifi...

Cherrypy : Do I really need to put it behind a frontend ?

Hi. I've been working on a python web app using cherrypy and read it'd be more "robust" to use it as a backend, so I gave it a try. Shortly put, running some benchmarks on a page doing some database operations and serving static & dynamic content has shown that plain cherrypy was twice as fast than nginx and memcached, and about half f...

Dynamic Image Caching

I have a CherryPy app that dynamically generates images, and those images are re-used a lot but generated each time. The image is generated from a querystring containing the variables, so the same query string will always return the same image (until I rewrite the generation code) and the images are not user-specific. It occurred to me ...

Bind arbitrary Python objects to CherryPy sessions

I'm using CherryPy to make a web-based frontend for SymPy that uses an asynchronous process library on the server side to allow for processing multiple requests at once without waiting for each one to complete. So as to allow for the frontend to function as expected, I am using one process for the entirety of each session. The client-s...

How to decode Get/Post Request headers into tuples using Cherry Py?

Ok. I've been told by at least one really helpful individual who believes that its easy to decode and parse a GET/POST request header from within CherryPy. I've been here: http://www.cherrypy.org/wiki/BuiltinTools#tools.decode but it doesn't give you an example. Can someone direct me to a more helpful example? ...

How can I use multiple databases in the same request in Cherrypy and SQLAlchemy?

Hey SO'ers, My app connects to multiple databases using a technique similar to this. It works so long as I don't try to access different databases in the same request. Having looked back to the above script I see they have written a comment to this end: SQLAlchemy integration for CherryPy, such that you can access multiple databases, b...

Design pattern for multiple consumers and a single data source.

I am designing a web interface to a certain hardware appliance that provides its own custom API. Said web interface can manage multiple appliances at once. The data is retrieved from appliance through polling with the custom API so it'd be preferable to make it asynchronous. The most obvious thing is to have a poller thread that polls ...

CherryPy How to respond with JSON?

In my controller/request-handler, I have the following code: def monkey(self, **kwargs): cherrypy.response.headers['Content-Type'] = "application/json" message = {"message" : "Hello World!" } return message monkey.exposed = True And, in my view, I've got this javascript: $(function() { var body = document.getElementsByTagNa...