Magic Method Exercises

In Recipe #1, add a dump(tag, filename) function that generates output to a UTF-8 encoded file. (That is, it should be able to generate HTML pages that correctly display international characters.)

The calls to dojo.require() are hard coded inside the dijit function, which in general is not a good idea. Make it so that the require JavaScript section is dynamically generated based on what tags you use.

Add a load(filename) function that converts an XML file to a hierarchy of Tag objects. You should be able to process XML files like this:

        This is a Button <button>Click me!</button>
        This is a TextBox <textbox value="The cow jumped over the moon, and it exploded" />
        This is a CheckBox <checkbox checked="checked" />
        This is a DateTextBox <datetextbox value="1998-03-23" />

Write a decorator for Django (or your web framework of choice) that allows you to do this:

def view(request):
    return dict(name=request['name'], place=request['place'])

Where view.xml is an XML template file that specifies a Dijit interface.

In Recipe #2, add a load(filename) function that converts an XML file to a ContainerWrapper object. You should be able to handle XML files like this:

    <Button text="One" />
    <Button text="Two" />
    <Button text="Tree" />

        <Button text="Apple" />
        <Button text="Banana" />
        <Button text="Cranberry" />

Implement Recipe #2 for wxPython, PyQt, or any other GUI framework of your choice.