Tutorial Step 9 - Other useful tools

In this last tutorial step we will show how to use some other specific Erlang Web's features.

Switching the web servers

Since Erlang Web provides web server's level abstraction we do not need to bother about the server we will be running on the top of. Nevertheless in some situation we would like to change it and try to run the service on the different type of the software. In order to switch from the Inets (default one, included in the standard OTP release) to Yaws (included in Erlang Web, homepage: http://yaws.hyber.org) we must change only two things:

Unless we used the server specific functions (what is not recommended though), we should be able to run the server immediately.

Switching the database back end

So far, we were using Mnesia (standard OTP DBMS) as our model holder. But it is no big deal to switch to CouchDB backend - it could be done in as easy way as switching the web servers. In order to do this, we must do the following things:

Of course there is no need to call mnesia:create_table/2 any more. Since CouchDB is a schema-less database we do not need to set it up before use.

Template inheritance

The template inheritance has been described fully here.

Paginating the items list

As the service is getting larger and larger it will be totally unreasonable to list all the available items on the one page. We should better think about partitioning and paginating the content. It could be done by using wpart_paginate mechanism. The browser:list_all/1 saves the properly formatted items under the items key in the request dictionary. Let's see how we can change our view to display only a part of the collection, for example - 5 items per page:

And that is really all...

Tutorial/Step9_OtherTools (last edited 2009-05-07 10:49:40 by Michal Ptaszek)