_missing = object()

class cached_property(object):
    """A decorator that converts a function into a lazy property.  The
    function wrapped is called the first time to retrieve the result
    and than that calculated result is used the next time you access
    the value::

        class Foo(object):

            @cached_property
            def foo(self):
                # calculate something important here
                return 42

    The class has to have a `__dict__` in order for this property to
    work.
    """
    # implementation detail: this property is implemented as non-data
    # descriptor.  non-data descriptors are only invoked if there is
    # no entry with the same name in the instance's __dict__
    # this allows us to completely get rid of the access function call
    # overhead.  If one choses to invoke __get__ by hand the property
    # will still work as expected because the lookup logic is replicated
    # in __get__ for manual invocation.

    def __init__(self, func, name=None, doc=None):
        self.__name__ = name or func.__name__
        self.__doc__ = doc
        self.func = func

    def __get__(self, obj, type=None):
        if obj is None:
            return self
        value = obj.__dict__.get(self.__name__, _missing)
        if value is _missing:
            value = self.func(obj)
            obj.__dict__[self.__name__] = value
        return value

def import_string(import_name, silent=False):
    """Imports an object based on a string.  This is useful if you want to
    use import paths as endpoints or something similar.  An import path can
    be specified either in dotted notation (``xml.sax.saxutils.escape``)
    or with a colon as object delimiter (``xml.sax.saxutils:escape``).

    If `silent` is True the return value will be `None` if the import fails.

    :param import_name: the dotted name for the object to import.
    :param silent: if set to `True` import errors are ignored and
                   `None` is returned instead.
    :return: imported object
    """
    try:
        if ':' in import_name:
            module, obj = import_name.split(':', 1)
        elif '.' in import_name:
            module, obj = import_name.rsplit('.', 1)
        else:
            return __import__(import_name)
        return getattr(__import__(module, None, None, [obj]), obj)
    except (ImportError, AttributeError):
        if not silent:
            raise

class HttpResponse(object):
    def __init__(self, status_code, content_type=None, body=''):
        self.status_code = status_code
        self.content_type = content_type or 'text/plain'
        self.body = body

    def as_bytes(self):
        response = 'HTTP/1.1 %s\r\n' % self.status_code
        response += 'Content-Length: %s\r\n' % len(self.body)
        response += 'Content-Type: %s\r\n\r\n' % self.content_type
        response += self.body
        return response

def json_timestamp(dt):
    epoch = int(dt.strftime('%s'))
    usec = dt.microsecond
    timestamp = epoch + (usec / 1000000.0)
    return timestamp

@@ -1,16 +1,36 @@
+import collections%0A%0A
 _missing = objec
@@ -2928,16 +2928,1400 @@
 sponse%0A%0A
+class RingBuffer(collections.deque):%0A    %22%22%22%0A    inherits deque, pops the oldest data to make room for the newest data%0A    when size is reached.%0A %0A    http://www.daniweb.com/forums/post202523-3.html%0A    %22%22%22%0A    def __init__(self, size):%0A        collections.deque.__init__(self)%0A        self.size = size%0A %0A    def remove(self, item):%0A        raise TypeError('you cannot remove an item from the ring buffer')%0A %0A    def __delitem__(self, x):%0A        raise TypeError('you cannot slice or delete from the ring buffer')%0A %0A    def clear(self):%0A        super(RingBuffer, self).clear()%0A        self.append = type(self).append%0A %0A    def _full_append(self, item):%0A        collections.deque.append(self, item)%0A        # full, pop the oldest item, left most item%0A        self.popleft()%0A %0A    def append(self, item):%0A        collections.deque.append(self, item)%0A        if len(self) == self.size:%0A            self.append = self._full_append%0A %0A    def after_match(self, func, full_fallback=False):%0A        %22%22%22Returns an iterator for all the elements after the first%0A        match.  If %60full_fallback%60 is %60True%60, it will return all the%0A        messages if the function never matched.%0A        %22%22%22%0A        iterator = iter(self)%0A        for item in iterator:%0A            if func(item):%0A                return iterator%0A        if full_fallback:%0A            iterator = iter(self)%0A        return iterator%0A%0A
 def json

Add back RingBuffer for the BroadcastCometHandler