AxKit2

 view release on metacpan or  search on metacpan

demo/webmail/js/prototype.js  view on Meta::CPAN

  onComplete: function() {
    Ajax.activeRequestCount--;
  }
});

Ajax.Base = function() {};
Ajax.Base.prototype = {
  setOptions: function(options) {
    this.options = {
      method:       'post',
      asynchronous: true,
      parameters:   ''
    }
    Object.extend(this.options, options || {});
  },

  responseIsSuccess: function() {
    return this.transport.status == undefined
        || this.transport.status == 0
        || (this.transport.status >= 200 && this.transport.status < 300);
  },

demo/webmail/js/prototype.js  view on Meta::CPAN

    if (parameters.length > 0) parameters += '&_=';

    try {
      this.url = url;
      if (this.options.method == 'get' && parameters.length > 0)
        this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;

      Ajax.Responders.dispatch('onCreate', this, this.transport);

      this.transport.open(this.options.method, this.url,
        this.options.asynchronous);

      if (this.options.asynchronous) {
        this.transport.onreadystatechange = this.onStateChange.bind(this);
        setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
      }

      this.setRequestHeaders();

      var body = this.options.postBody ? this.options.postBody : parameters;
      this.transport.send(this.options.method == 'post' ? body : null);

    } catch (e) {

lib/AxKit2/Plugin.pm  view on Meta::CPAN

In order to hook into a particular phase of the request you simply write a
method called C<hook_NAME> where C<NAME> is the name of the hook you wish to
connect to.

Example:

  sub hook_logging {

If your plugin needs to hook into the same hook more than once, you will need
to write a C<register()> method as shown above. This is usually the case if you
need continuations for some reason (such as doing asynchronous I/O).

All hooks are called as a method on an instance of the plugin object. Params
below are listed without the C<$plugin> or C<$self> object as the first param.

For some plugins returning C<CONTINUATION> is valid. For details on how
continuations work in AxKit2 see L</CONTINUATIONS> below.

In all cases below, returning C<DECLINED> means other plugins/methods for the
same hook get called. Any other return value means execution stops for that
hook.

lib/AxKit2/Plugin.pm  view on Meta::CPAN


A typical usage of this is when you need to perform an action that may take some
time. An example of this is disk I/O - typical I/O in the common POSIX
read/write style APIs occurs in a blocking manner - when you ask for a C<read()>
the disk seeks to the position you need it to go to when it can do so and the
read is performed as soon as possible before the API call returns. This may take
very little CPU time because the OS has to wait until the disk head is in the
correct position to perform the actions requested. But it does take "clock" time
which can be put to better use responding to other requests.

In asynchronous I/O the action is requested and a callback is provided to
be called when the action has occured. This allows the event loop to continue
processing other requests while we are waiting for the disk.

This is better explained with a simple example. For this example we'll take the
C<stat()> system call in an attempt to find out if the filename we are
requesting is a directory or not. In perl we would normally perform this with
the following code:

    sub hook_response {
        my $self = shift;

plugins/magic_mime_map  view on Meta::CPAN


magic_mime_map - Use File::MMagic to set MIME type

=head1 SYNOPSIS

    Plugin magic_mime_map

=head1 DESCRIPTION

This plugin uses C<File::MMagic> to set the MIME type of the request. This has
the potential to open the file and be a synchronous action, so use with
caution.

=cut

use File::MMagic;

my $mm = File::MMagic->new();

sub hook_mime_map {
    my ($self, $hd, $filename) = @_;



( run in 0.263 second using v1.01-cache-2.11-cpan-0d8aa00de5b )