Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jsmith (3335)

  (email not shown publicly)

I'm a web applications developer trying to bring all things open source to all things humanities at Texas A&M University.

Journal of jsmith (3335)

Tuesday February 19, 2008
11:37 PM

RDF::Server almost done

[ #35698 ]

By the power invested in me by Moose, I can do:

  package My::Server;

  use RDF::Server;
  protocol 'HTTP';
  interface 'REST';
  semantic 'Atom';

  render xml => 'Atom';
  render rdf => 'RDF';

Then, to instantiate it, I use the following configuration (as an example):

  my $server = My::Server -> new(
          default_renderer => 'Atom',
          handler => [ service => (
                  path_prefix => '/',
                  workspaces => [
                          title => 'Workspace',
                          collections => [
                                          title => 'All of Foo',
                                          path_prefix => 'foo/',
                                          model => {
                                                  namespace => '',
                                                  class => 'RDFCore'
          } ]

This results in the following urls:

- / - an app:service document
- /foo/ - an app:collection document (because there's no path component configured for the app:workspace)
- /foo/$id - an atom:entry document for the RDF resources centered around$id.

The handler attribute is supposed to be a code ref that returns the information (so it can be dynamically built with each request if you really want it to be), but the module that defines the Atom semantics overloads the handler attribute's Moose type and allows coercion. This should allow configuration to be from a config file if the right Moose role is included in the server class.

I might make the rendering management configurable instead of part of the module definition. Unlike the protocol, interface, and semantic modules, the renderers don't include code, attributes, or expectations in the server class.

So far, I have passing tests for fetching app:service and app:collection documents and creating, fetching, and adding triples to RDF resources.

One thing I'm doing that might not be quite 'usual' is that I'm treating an RDF model as a collection of RDF resource documents. RDF resource documents are a collection of RDF triples centered around a particular RDF subject. I'm not treating the entire body of knowledge in the model as a single document. That's part of what's in the Atom semantic I'm working with.

Hopefully more next week, including something on CPAN with a lot more documentation than what I have now.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Hey, curious about your goals moving this forward. There are a couple of REST and ATOM projects going on around Catalyst, and since both are personal hobbies of mine I'd be interested in seeing if there are any overlaps or possible collaborations. Best to get me at
    Waiting on the Road to Eventually, I lost my Place On Line
    • The framework is designed in part to make the data model accessible, so I don't see why I (or someone) couldn't make a Catalyst adaptation.

      The RDF::Server stuff is a small part of a larger project that is being built with Catalyst. I'm separating out the RDF::Server framework since it can be standalone.
  • That API is just screaming out for something like...

    my $server = PDF::Server->from_yaml( from_yaml_file( 'config.yaml' );
    • Something like this?

        my $class = RDF::Server -> build_from_config({
                interface => 'REST',
                protocol => 'HTTP',
                semantic => 'Atom',
                renderers => {
                        'rdf' => 'RDF',
                        'atom' => 'Atom',