Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Looking for REST equivalent to WWW::Mechanize

by talexb (Chancellor)
on Sep 11, 2006 at 20:52 UTC ( [id://572396]=perlquestion: print w/replies, xml ) Need Help??

talexb has asked for the wisdom of the Perl Monks concerning the following question:

I'm developing a web/REST application using CGI::Application and assorted plugins (CGI::Application::Plugin::Session to handle session cookies, CGI::Application::Plugin::TT for Template::Toolkit, CGI::Application::Plugin::Stream to handle file downloads and CGI::Application::Plugin::DBH to handle DBI), and the web end is now pretty squeaky clean, thanks to some testing using Test::More and WWW::Mechanize.

Now it's time for me to do the REST side of the application -- just a matter of making up some XML templates to match the HTML templates. Of course, I want to do this while continuing to use Test::More so that I can start (finally) to do test-driven development. So what I want is something like REST::Mechanize. Has anyone developed such a tool? I could definitely make use of it.

As a side note (but a relevant one) I note that curl doesn't send cookie information after a re-direct (1), which prevents me from using it to do my testing. I am using URL rewriting to provide my REST-type interface -- that's where the re-direction comes in.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

1. See this post for more information.

Replies are listed 'Best First'.
Re: Looking for REST equivalent to WWW::Mechanize
by jasonk (Parson) on Sep 12, 2006 at 15:08 UTC

    Strangely enough, just before reading your question I happened to click on WWW::Mechanize::XML in the CPAN nodelet... I haven't used it, but it looks like what you are looking for...

    We're not surrounded, we're in a target-rich environment!
Re: Looking for REST equivalent to WWW::Mechanize
by markjugg (Curate) on Sep 12, 2006 at 18:08 UTC
    I find this post confusing. I understand REST to be centered around clean URLs. In that case, maybe CGI::Application::Dispatch is what you are looking for. It works well for me. You mentioned delivering XML, but that's not technically part of REST.

    On the other hand, WWW::Mechanize should have little trouble retrieving XML. Your application just needs to serve it.

    It would be helpful to see some more concrete examples or description of the problem you are running into.

      It may be that my post is confusing .. I'm still trying to understand how it all works, and what tools to use from CPAN.

      I'm working from the REST definition in the REST article:

        REST strictly refers to a collection of architectural principles (described below). The term is also often used in a looser sense to describe any simple interface that uses XML (or YAML, JSON, plain text) over HTTP without an additional messaging layer such as SOAP.
      I'm trying to emit XML in response to clean URLs with a view towards providing a simple interface for the web application that I'm writing.

      My plan is that I'll provide clients with Perl or shell scripts to upload/download files, without having to worry about providing something that needs to parse XHTML web pages -- instead, they'll be able to talk XML, which will be strictly data, no ornamentation. This is a follow-on to my previous post on the same topic.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      After fiddling a bit with XML, I decided to take an easier approach, and decided to use YAML instead of XML. I now have a working test suite that tests against both the XHTML and the REST/YAML interfaces, using the same test data. I ended up just using LWP::UserAgent for that -- WWW::Mechanize wasn't necessary for testing of the REST/YAML side.

      And I need to thank you for that -- you stated that XML wasn't necessarily part of REST, and you're right. Once again, Perlmonks provides great feedback, something that I rely on, since I'm the only Perl developer at my employer who is focussing on the web.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Looking for REST equivalent to WWW::Mechanize
by Anonymous Monk on Sep 12, 2006 at 10:01 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://572396]
Approved by GrandFather
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2024-07-21 02:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.