Read on and leave a comment
or return to our portfolio.

Archive for September, 2006

14 Sep 2006

by Noel

CMS software for QMUL

We “went live” today with our second project for Queen Mary, University of London: a content management system for publishing course and staff homepages.

The system is simple and intuitive: each homepage consists of a single page of HTML, and doubles as an online filestore. Members of staff can upload files such as lecture notes and slides, and visitors to the page can download them simply by clicking on a hyperlink. We use the metaphor of attachments to relate this back to the familiar process of writing an email.

The main page editor screen is split into two halves: a WYSIWYG HTML editor (we used TinyMCE) and a list of attachments (complete with controls for uploading, renaming and deleting files). A separate management interface allows administrative staff to set up homepages for new courses and members of staff, assign permissions for who can edit what, and flag external pages that are held off-site and not maintained with our software.

All of this new functionality is integrated into our existing software for registering students on courses. Members of staff access all their pages through a control panel that displays only the information they need, and everything is nicely integrated with QMUL’s IDCheck single sign-on service.

Behind the scenes, the code for the CMS is based on a prototype for our new component-oriented web UI library, LyluxUI. We still have a way to go before the code is ready for open release, but it will eventually be available for public consumption alongside our other open source libraries, Snooze and Unlib.

Posted in Business | Comments Off on CMS software for QMUL

13 Sep 2006

by Noel

A live hash-table using XML-RPC

I received a question the other day about using our XML-RPC library, and thought I’d put the response here. It’s still a simple example, but it illustrates one or two things. You must be running PLT Scheme 352.5 or greater for this to work, as we’re using some nifty new features that make things more stable.

I’m going to implement a “live hash-table”. By this, I mean I’m going to have a PLT Scheme hash-table that I can access from anywhere via XML-RPC. I created a “testing” directory in in the “servlets” directory of my server. Inside of that “testing” directory, I created a servlet called “live-hash.ss”. It looks like this:

(module live-hash mzscheme

(require
;; For the 'xmlrpc-server' and 'add-handler' functions
   (planet "xmlrpc-module-servlet.ss"
("schematics" "xmlrpc.plt" 1 3))
;; For 'raise-exn:xmlrpc'
   (planet "base.ss"
("schematics" "xmlrpc.plt" 1 3))
)

(provide interface-version manager timeout start)

;; I'm using 'equal here so that strings can be
  ;; used as hashtable keys.
  (define table (make-hash-table 'equal))

;; CONTRACT
  ;; insert : (U string number) any -> bool
  ;; PURPOSE
  ;; The 'insert' method will insert a value into the
  ;; hashtable, and return #t. We return a boolean in all
  ;; casees because XML-RPC has no natural coercion for the
  ;; #<void> value.
  (define (insert key value)
(if (or (string? key)
(number? key))
(begin (hash-table-put! table key value) #t)
#f))

;; CONTRACT
  ;; get : (U string number) -> any
  ;; PURPOSE
  ;; The 'get' method returns a value from the hashtable, or
  ;; raises an XML-RPC fault.
  (define (get key)
(hash-table-get
table key
(lambda ()
(raise-exn:xmlrpc
(format "No value in hash for key '~a'" key))
)))

;; Make 'insert' and 'get' available to the
  ;; outside world.
  (add-handler 'insert insert)
(add-handler 'get get)

)

If you can execute this in the “module” language of DrScheme and not get any errors, there’s a good chance that it will run under the webserver. At least, that’s a first step.

On the client side, I have some code that declares that the PLT webserver running on my local machine (with the “live-hash.ss” servlet) is an XML-RPC endpoint. I then map two local functions, “ins” and “get” to the remote methods provided by the server. Lastly, I do a quick test: I insert some data, and then request it back.

The client-side looks like:

(module live-hash-client mzscheme

(require (planet "xmlrpc.ss"
("schematics" "xmlrpc.plt" 1 3)))

;; Declare where the endpoint for this XML-RPC call is
  (define local (xmlrpc-server
"localhost"
8080
"servlets/testing/live-hash.ss"))

;; Define the mappings from local method calls to remove
  ;; method calls. In this case, the local name "ins" is bound
  ;; to the method "insert" running on the server.
  (define ins (local 'insert))
(define get (local 'get))

;; Try inserting some data
  (for-each (lambda (key val)
(ins key val))
'(1 2 3 4 5)
'(a b c d e))

;; Now, try retrieving it
  (for-each (lambda (key)
(printf "K: ~a V: ~a~n" key (get key)))
'(1 2 3 4 5))

)

Again, I’m working under the “module” language here.

If all goes well, you can run the client-side, and see the data go round-trip to the server. Well, you can’t exactly “see” it, but you can guess that it goes round-trip to the server.

Welcome to DrScheme, version 352.5-svn28aug2006.
Language: (module ...).
K: 1 V: a
K: 2 V: b
K: 3 V: c
K: 4 V: d
K: 5 V: e

That’s perhaps not a lot to be getting on with; there’s more documentation in the “doc.txt” file included in the distribution. And it’s not quite as cool as Tony’s explorations with Erlang, but… well, this library has been around for a while, and occasionally, someone finds a use for it.

(Pretty-printing of code to HTML made possible by Paste Scheme at scheme.dk. Woot.)

Posted in Code | Comments Off on A live hash-table using XML-RPC