Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  NET::JIFTY (3)

.ds Aq ’


Net::Jifty - interface to online Jifty applications



    use Net::Jifty;
    my $j = Net::Jifty->new(
        site        =>,
        cookie_name => MUSHROOM_KINGDOM_SID,
        email       =>,
        password    => melange,

    # the story begins
    $j->create(Hero => name => Mario, job => Plumber);

    # find the hero whose job is Plumber and change his name to Luigi
    # and color to green
    $j->update(Hero => job => Plumber,
        name  => Luigi,
        color => Green,

    # win!
    $j->delete(Enemy => name => Bowser);


Jifty is a full-stack web framework. It provides an optional REST interface for applications. Using this module, you can interact with that REST interface to write client-side utilities.

You can use this module directly, but you’ll be better off subclassing it, such as what we’ve done for Net::Hiveminder.

This module also provides a number of convenient methods for writing short scripts. For example, passing use_config => 1 to new will look at the config file for the username and password (or SID) of the user. If neither is available, it will prompt the user for them.


    CRUD - create, read, update and delete.


Create a new object of type MODEL with the FIELDS set.


Find some MODEL where KEY is VALUE and return it.


Find some MODEL where KEY is VALUE and set FIELDS on it.

delete MODEL, KEY => VALUE

Find some MODEL where KEY is VALUE and delete it.

    Other actions


Searches for all objects of type MODEL that satisfy FIELDS. The optional OUTCOLUMN defines the output column, in case you don’t want the entire records.


Perform any ACTION, using ARGS. This does use the REST interface.

    Arguments of actions

Arguments are treated as arrays with (name, value) pairs so you can do the following:

    $jifty->create(Model, x => 1, x => 2, x => 3 );

Some actions may require file uploads then you can use hash reference as value with content, filename and content_type fields. filename and content_type are optional. content_type by default is ’application/octeat-stream’.

validate_action_args action => args

Validates the given action, to check to make sure that all mandatory arguments are given and that no unknown arguments are given.

Arguments are checked CRUD and act methods if ’strict_arguments’ is set to true.

You may give action as a string, which will be interpreted as the action name; or as an array reference for CRUD - the first element will be the action (create, update, or delete) and the second element will be the model name.

This will throw an error or if validation succeeds, will return 1.

    Specifications of actions and models

get_action_spec NAME

Returns the action spec (which arguments it takes, and metadata about them). The first request for a particular action will ask the server for the spec. Subsequent requests will return it from the cache.

get_model_spec NAME

Returns the model spec (which columns it has). The first request for a particular model will ask the server for the spec. Subsequent requests will return it from the cache.



Each Net::Jifty object will do the following upon creation:
Read config ..but only if you use_config is set to true.
Log in ..unless a sid is available, in which case we’re already logged in.

This method is called automatically when each Net::Jifty object is constructed (unless a session ID is passed in).

This assumes your site is using Jifty::Plugin::Authentication::Password. If that’s not the case, override this in your subclass.


This will ask the user for her email and password. It may do so repeatedly until login is successful.


This uses the Jifty web services API to perform ACTION. This is not the REST interface, though it resembles it to some degree.

This module currently only uses this to log in.

    Requests helpers

post URL, ARGS

This will post ARGS to URL. See the documentation for method about the format of URL.


This will get the specified URL with ARGS as query parameters. See the documentation for method about the format of URL.

method METHOD, URL[, ARGS]

This will perform a METHOD (GET, POST, PUT, DELETE, etc) using the internal LWP::UserAgent object.

URL may be a string or an array reference (which will have its parts properly escaped and joined with /). URL already has prepended to it, and .yml appended to it, so you only need to pass something like model/YourApp.Model.Foo/name, or [qw/model YourApp.Model.Foo name].

This will return the data structure returned by the Jifty application, or throw an error.

form_url_encoded_args ARGS

This will take an array containing (name, value) argument pairs and convert those arguments into URL encoded form. I.e., (x => 1, y => 2, z => 3) becomes:


These are then ready to be appened to the URL on a GET or placed into the content of a PUT. However this method can not handle file uploads as they must be sent using ’multipart/form-date’.

See also /form_form_data_args ARGS and Arguments of actions.

form_form_data_args ARGS

This will take an array containing (name, value) argument pairs and convert those arguments into HTTP::Message objects ready for adding to a ’mulitpart/form-data’ HTTP::Request as parts with something like:

    my $req = HTTP::Request->new( POST => $uri );
    $req->header(Content-type => multipart/form-data);
    $req->add_part( $_ ) foreach $self->form_form_data_args( @args );

This method can handle file uploads, read more in Arguments of actions.

See also /form_form_data_args ARGS and Arguments of actions.

join_url FRAGMENTS

Encodes FRAGMENTS and joins them with /.

escape STRINGS

Returns STRINGS, properly URI-escaped.

    Various helpers

email_eq EMAIL, EMAIL

Compares the two email addresses. Returns true if they’re equal, false if they’re not.

is_me EMAIL

Returns true if EMAIL looks like it is the same as the current user’s.

email_of ID

Retrieve user ID’s email address.

load_date DATE

Loads DATE (which must be of the form YYYY-MM-DD) into a DateTime object.


Retrieves the sid from the LWP::UserAgent object.

    Working with config


This will return a hash reference of the user’s preferences. Because this method is designed for use in small standalone scripts, it has a few peculiarities.
o It will warn if the permissions are too liberal on the config file, and fix them.
o It will prompt the user for an email and password if necessary. Given the email and password, it will attempt to log in using them. If that fails, then it will try again.
o Upon successful login, it will write a new config consisting of the options already in the config plus session ID, email, and password.

This will warn about (and fix) config files being readable by group or others.


This transforms the config file into a hashref. It also does any postprocessing needed, such as transforming localhost to (due to an obscure bug, probably in HTTP::Cookies).

The config file is a YAML document that looks like:

    password: drowssap
    sid: 11111111111111111111111111111111


This will write the config to disk. This is usually only done when a sid is discovered, but may happen any time.

filter_config [DIRECTORY] -> HASH

Looks at the (given or) current directory, and all parent directories, for files named $self->filter_file. Each file is YAML. The contents of the files will be merged (such that child settings override parent settings), and the merged hash will be returned.

What this is used for is up to the application or subclasses. Net::Jifty doesn’t look at this at all, but it may in the future (such as for email and password).


Jifty, Net::Hiveminder


Shawn M Moore, <sartak at>

Ruslan Zakirov, <ruz at>

Jesse Vincent, <jesse at>


Andrew Sterling Hanenkamp, <>,


Please report any bugs or feature requests to bug-net-jifty at, or through the web interface at <>.


Copyright 2007-2009 Best Practical Solutions.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 862: alternative text ’/form_form_data_args ARGS’ contains non-escaped | or /
Around line 877: alternative text ’/form_form_data_args ARGS’ contains non-escaped | or /
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 NET::JIFTY (3) 2011-01-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.