Opened 12 years ago

Closed 11 years ago

#1619 defect closed duplicate (duplicate)

Reloading html page with unchanged CSS generates traceback

Reported by: jacob Owned by:
Priority: normal Milestone: Web2-Gold-Master
Component: web2 Keywords:
Cc: Branch:

Description (last modified by Jean-Paul Calderone)

Here is an example, based on the web2 demo file. To repeat:

  1. Put this file in a directory
  2. Create a CSS file called "schedcss" in the same directory. Suitable content is "h1 {font-size: 10pt}"
  3. Start server with "twistd -ny <filename>
  4. Point browser to "http://localhost:8080/". This should load fine.
  5. Press reload button. This should generate traceback.
  6. Do "touch schedcss".
  7. Press reloadbutton again. This should not generate a traceback.

#!/usr/bin/env python2.4
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.

"""I am a simple test resource.
import os.path
import cgi as pycgi

from twisted.web2 import log, iweb
from twisted.web2 import static, wsgi, resource, responsecode, twcgi
from twisted.web2 import resource, stream, http, http_headers
from twisted.internet import reactor

class CSS(resource.Resource):
    def render(self, req):
        # This simulates what happens if the file was unchanged
        # It generates the traceback
        return http.Response(
            {'content-type': http_headers.MimeType('text', 'css')},
        # This has a valid stream. We don't get a traceback
        return http.Response(
            {'content-type': http_headers.MimeType('text', 'css')},
        # This shows what would be returned if the file is changed 
        return http.Response(
            {'content-type': http_headers.MimeType('text', 'css')},
            'h1 {font-size: 10pt}')

class Toplevel(resource.Resource):

    def render(self, req):
        contents = """<html>
<head><title>Twisted.web2 demo server</title>
<link rel="stylesheet" type="text/css" href="mycss"/>

<h1>Hello!</h1>  This is a twisted.web2 demo.

        return http.Response(
            {'content-type': http_headers.MimeType('text', 'html')},

    child_mycss = static.File('./schedcss')
    #child_mycss = CSS()

if __name__ == '__builtin__':
    from twisted.application import service, strports
    from twisted.web2 import server, vhost, channel

    test = Toplevel()

    # Setup default common access logging
    res = log.LogWrapperResource(test)

    # Create the site and application objects
    site = server.Site(res)
    application = service.Application("demo")
    # Serve it via standard HTTP on port 8080
    s = strports.service('tcp:8080', channel.HTTPFactory(site))

2006/04/02 20:35 CEST [-] twistd 2.2.0 (/usr/bin/python2.3 2.3.5) starting up
2006/04/02 20:40 CEST [HTTPChannel,0,] Traceback (most recent call last):
          File "/usr/lib/python2.3/site-packages/twisted/internet/", line 307, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "/usr/lib/python2.3/site-packages/twisted/web2/", line 373, in _cbFinishRender
          File "/usr/lib/python2.3/site-packages/twisted/internet/", line 229, in callback
          File "/usr/lib/python2.3/site-packages/twisted/internet/", line 294, in _startRunCallbacks
        --- <exception caught here> ---
          File "/usr/lib/python2.3/site-packages/twisted/internet/", line 307, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "/usr/lib/python2.3/site-packages/twisted/web2/", line 415, in writeResponse
          File "/usr/lib/python2.3/site-packages/twisted/web2/", line 42, in close
        exceptions.AttributeError: 'NoneType' object has no attribute 'close'

Change History (5)

comment:1 Changed 12 years ago by jacob

Type: enhancementdefect

comment:2 Changed 12 years ago by Jean-Paul Calderone

Description: modified (diff)

comment:3 Changed 11 years ago by Glyph

Milestone: Web2-Gold-Master

comment:4 Changed 11 years ago by jknight

Resolution: duplicate
Status: newclosed

Duplicate of the (now fixed) bug #1437.

comment:5 Changed 7 years ago by <automation>

Owner: jknight deleted
Note: See TracTickets for help on using tickets.