python - Twisted, deferred requests and File vs ErrorPage -


I am currently creating an HTTP server with Python / twisted.

Store this server with another web server, store it locally and send feedback to the customer. If he has to face 404, then he should try to serve the local file, if there is no local file, then he will fail.

To achieve this, I am using different requests. My code looks almost like this:

  class remote file (resource): isLeaf = True def render_GET (Self, requested): # Downloading related file on remote server # Service_local_file` When a return is returned NOT_DONE_YET def service_lock_file (auto, request): if self.file_exists_for_request (requested): fileResource = File (filename) fileResource.render ( Request) else: page = NoResource ("no such file") html = Page Render (requested) # The next two lines are my problem request. Type (html) request.finish ()  

I had to add the last two lines (type ) and full () ) To really get the request to finish. I do not need these rows for the file resource, because it handles / eliminates itself by typing, unlike the nosers

This is not a problem, but it turns out that this page variable is not hard, and it's actually a fallback on my class Is the attribute, which should be the resource This means that in the future, I want to change it with the default file in which case I have to modify my code ...

Am I doing something wrong, Or is this an inconsistency in the file interface and error page ?

There is only one sign in your question:

  return NOT_DONE_YET < / Code> 

This is a part of an IRSorror sign that if it is returning a string that requires the caller to explicitly "finish" the request before writing on request Whether or not IRSOSAR is taking responsibility for doing those things or not.

Check the value of whatever you are calling on render and work accordingly.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -