Classic Note Entries

Maki Issues

  • Does maki really need PyXML?
  • As of 2010-09-25 Maki had 924 downloads

How to implement AtomPub
This is using rack (a ruby thing) but it is the same as WSGI

def call(env)
  uri = path(env)
  case env['REQUEST_METHOD']
  when 'GET' then get(uri, env)
  when 'POST' then post(uri, env)
  when 'PUT' then put(uri, env)
  when 'DELETE' then delete(uri, env)
  end
end
# chop off the common prefix, leaving what we dispatch on
def path(env)
  env['REQUEST_URI'][@base.length .. -1]
end
def get(uri, env)
  headers = {}
  type = nil
  case uri
  when '/'
    rep = VDC.new(@cloud).representation
    type = 'VDC'
  when %r{^/vnets/(.*)$}
    rep = get_vnet($1)
    type = 'VNet' if rep
  # ...lots more regexps elided...
  if (type)
    headers['Content-Type'] = "application/vnd.com.sun.cloud.#{type}+json"
    [ 200, headers, rep ]
  else
    headers['Content-Type'] = "text/plain"
    [ 404, headers, "Can't fetch #{uri}" ]
  end
end