view jabberbot/ @ 5206:64854adb52fc

add Expires header with now + 10 seconds for AttachFile do=get and do=box User's browser shall usually request the wiki content as it might change fast. It'll either get a 200 OK response with the content, or (if content was not modified) a 304 NOT MODIFIED response. Without the Expires header, browser does not request the content (I guess it uses some builtin heuristics then to determine when to do a request, and that that might be much too slow for fast changing wikis).
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Oct 2009 15:54:36 +0200
parents 8ec6cc1a909f
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - Out Of Band Data (XEP-066) implementation

    This is used by the xmpp thread to send URIs to clients
    in a structured manner.

    @copyright: 2007 by Karol Nowak <>
    @license: GNU GPL, see COPYING for details.

from pyxmpp.message import Message
from pyxmpp.presence import Presence

def add_urls(stanza, data):
    """Adds a URL to a message or presence stanza

    Adds an <x> element qualified by the jabber:x:oob namespace
    to the stanza's payload

    @param stanza: message or presence stanza to add the URL info to
    @type stanza: pyxmpp.message.Message or pyxmpp.presence.Presence
    @param data: a list of dictionaries containing (url, description), as unicode
    @type data: list

    if not (isinstance(stanza, Presence) or isinstance(stanza, Message)):
        raise TypeError("Stanza must be either of type Presence or Message!")

    for piece in data:
        x_elem = stanza.add_new_content(u"jabber:x:oob", u"x")
        url = x_elem.newChild(None, u"url", None)
        desc = x_elem.newChild(None, u"desc", None)