You are not logged in Log in Join
You are here: Home » Members » Duncan Booth » Build a WAP site with Zope

Log in
Name

Password

 

Build a WAP site with Zope

This how-to describes how to use Zope to generate WML pages for use by WAP browsers. This is an ongoing work so please check back occasionally for changes, or mail me suggestions for improvements.

I say ongoing, but it is 15 months since this howto was last updated. In the meantime the biggest change has been the addition of Page Templates to Zope. Please don't use DTML to write your WAP pages. Please use Page Templates instead. Perhaps someday I may update this page to reflect that...

A site using the techniques described may be seen at http://www.rcp.co.uk/distributed/wapdemo (walkthrough with screenshots), or http://wap.autolocate.co.uk if you have a mobile phone.

What is WAP?

It is "The de facto worldwide standard for providing internet communications and advanced telephony services on digital mobile phones, pagers, personal digital assistants and other wireless terminals". Or at least that is what the wapforum mission statement says.

standard_wap_header

All of my WAP pages use standard_wap_header and standard_wap_footer instead of the html ones. The header contains the common XML header information, and it also tries to catch ordinary browsers visiting the site, redirecting them to an HTML page with suitable instructions. For debug support you can put ?debug=1 on the end of the URL to suppress the redirection.

<dtml-if "HTTP_USER_AGENT[:7]!='Mozilla'">
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<!-- content-type set in footer -->
<wml>
<dtml-else><dtml-unless debug><dtml-return "RESPONSE.redirect('/wap/notwml.html')"></dtml-unless>
</dtml-if>

standard_wap_footer

The content type must be set appropriately for all WML pages. To make life a little easier though, this version of the footer checks whether the browser is Netscape, and if it is, it sends plain text instead of wml. This lets you view any of your wml pages directly in Netscape (if you add the debug flag as above).

</wml>
<dtml-if "HTTP_USER_AGENT[:7]!='Mozilla'">
<dtml-call "RESPONSE.setHeader('Content-Type', 'text/vnd.wap.wml')">
<dtml-else>
<dtml-call "RESPONSE.setHeader('Content-Type', 'text/plain')">
</dtml-if>

standard_html_error

When a Zope error occurs, it tries to send back an error message which is in HTML format. Overriding standard_html_error makes it possible to format error messages for the WAP browser.

Preserving session information

There are two main options for preserving session state. One is to put everything in the URL, which is fine if you don't have too much information, but it makes the URLs quite long which in turn uses up the 1400 byte page size. The advantage to this is that pages are cachable, so with luck you can browse much of your site without ever making a phone call.

The other is to use SQLSession with cookie support disabled. If you try this, be sure to set cache expiry times for all of your pages.

Bitmaps

There is no direct support for WBMP files in Zope. It would be possible modify the mime types in lib/python/ofs/content_types.py, or create an extension that added the extra types so that WBMP files automatically get the correct mime type when uploaded. The other possible change would be to enhance the Image object type so that it could recognise the size fields of a WBMP object.

Another possible enhancement to Zope would be to install PIL and add support for WBMP. This would make it possible to upload GIF files and have Zope manage the conversion automatically. PIL support for WBMP format file is now available here.

At present, the only way to handle WBMP files in Zope is:

  • Create an image using your favourite image editor.
  • Convert it to a WBMP format. You can use Paintshop Pro, or Photoshop using a free plugin (MS windows only). Other tools exist for Macintosh or Java conversion. A web based convertor may be found at http://www.applepiesolutions.com/image2.wbmp/.
  • Upload it to your Zope server as a file object.
  • Edit the mime type, setting it to image/vnd.wap.wbmp
  • Insert literal image tags where needed in your WML.