view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Observe.pm view on Meta::CPAN
=head1 DESCRIPTION
Observe Engine events, for debugging purposes. Subclasses
L<Class::Publisher>.
C<Catalyst::Plugin::Observe> allows you to register your own callbacks
to specific Engine events (method calls), and to be notified through the
callback when they occur. When the Engine calls the event, your callback
will be called with the same arguments, which you can then display (etc.)
as necessary.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/RunAfterRequest.pm view on Meta::CPAN
use Moose::Role;
use MooseX::Types::Moose qw/ArrayRef CodeRef/;
use namespace::autoclean;
has callbacks => (
traits => ['Array'],
isa => ArrayRef[CodeRef],
default => sub { [] },
handles => {
run_after_request => 'push',
_callbacks => 'elements',
},
);
after finalize => sub {
my $self = shift;
for my $callback ($self->_callbacks) {
$self->$callback;
}
};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst.pm view on Meta::CPAN
return $class->registered_data_handlers;
}
}
sub setup_data_handlers {
my ($class, %data_handler_callbacks) = @_;
%data_handler_callbacks = (
%{$class->default_data_handlers},
%{$class->config->{'data_handlers'}||+{}},
%data_handler_callbacks);
$class->_data_handlers(\%data_handler_callbacks);
}
sub default_data_handlers {
my ($class) = @_;
return +{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/ActionRole/ProvidesMedia.pm view on Meta::CPAN
Scalar::Util::weaken($ctx);
my %media_actions = %{$self->media_actions};
unless(exists $media_actions{no_match}) {
$media_actions{no_match} = sub {
my ($req, %callbacks) = @_;
$ctx->res->status(406);
$ctx->res->content_type('text/plain');
my $allowed = join(',',(keys %callbacks));
$ctx->res->body("You requested a media type we don't support. Acceptable types are: $allowed");
};
}
my @forwards = map {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/TraitFor/Request/QueryFromJSONY.pm view on Meta::CPAN
using L<JSONY> and return the data references (could be a hashref, or arrayref
depending on the query construction.
If no @query_params are submitted, assume 'q' as the default.
The %options hash allows you to set callback to handle exceptional conditions. All callbacks
get invoked with two parameters, the current $request object, and the name of the
query parameter that caused the condition. For example the follow substitutes the string
'[]' when a $key is missing from %{$c->req->query_parameters}:
$c->req->query_data(qw/a b c/, +{
view all matches for this distribution
view release on metacpan or search on metacpan
Debian_CPANTS.txt view on Meta::CPAN
"libmarc-crosswalk-dublincore-perl", "MARC-Crosswalk-DublinCore", "0.02", "0", "0"
"libmarc-lint-perl", "MARC-Lint", "1.43", "0", "0"
"libmarc-perl", "MARC", "1.07", "0", "0"
"libmarc-record-perl", "MARC-Record", "2.0.0", "0", "0"
"libmarc-xml-perl", "MARC-XML", "0.88", "0", "0"
"libmasonx-interp-withcallbacks-perl", "MasonX-Interp-WithCallbacks", "1.18", "0", "0"
"libmath-algebra-symbols-perl", "Math-Algebra-Symbols", "1.21", "0", "0"
"libmath-basecalc-perl", "Math-BaseCalc", "1.013", "0", "0"
"libmath-basecnv-perl", "Math-BaseCnv", "1.4.75O6Pbr", "0", "0"
"libmath-bigint-gmp-perl", "Math-BigInt-GMP", "1.24", "1", "0"
"libmath-calc-units-perl", "Math-Calc-Units", "1.06", "0", "0"
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/JSON.pm view on Meta::CPAN
=over 4
=item allow_callback
Flag to allow callbacks by adding C<callback=function>. Defaults to 0
(doesn't allow callbacks). See L</CALLBACKS> for details.
=item callback_param
Name of URI parameter to specify JSON callback function name. Defaults
to C<callback>. Only effective when C<allow_callback> is turned on.
lib/Catalyst/View/JSON.pm view on Meta::CPAN
L<Encode::JavaScript::UCS> to use the encoding.
=head1 CALLBACKS
By default it returns raw JSON data so your JavaScript app can deal
with using XMLHttpRequest calls. Adding callbacks (JSONP) to the API
gives more flexibility to the end users of the API: overcome the
cross-domain restrictions of XMLHttpRequest. It can be done by
appending I<script> node with dynamic DOM manipulation, and associate
callback handler to the returned data.
lib/Catalyst/View/JSON.pm view on Meta::CPAN
Catalyst::View::JSON makes the data available as a (sort of)
JavaScript to the client, so you might want to be careful about the
security of your data.
=head2 Use callbacks only for public data
When you enable callbacks (JSONP) by setting C<allow_callback>, all
your JSON data will be available cross-site. This means embedding
private data of logged-in user to JSON is considered bad.
# MyApp.yaml
View::JSON:
lib/Catalyst/View/JSON.pm view on Meta::CPAN
my($self, $c) = @_;
$c->stash->{address} = $c->user->street_address; # BAD
$c->forward('View::JSON');
}
If you want to enable callbacks in a controller (for public API) and
disable in another, you need to create two different View classes,
like MyApp::View::JSON and MyApp::View::JSONP, because
C<allow_callback> is a static configuration of the View::JSON class.
See L<http://ajaxian.com/archives/gmail-csrf-security-flaw> for more.
=head2 Avoid valid cross-site JSON requests
Even if you disable the callbacks, the nature of JavaScript still has
a possibility to access private JSON data cross-site, by overriding
Array constructor C<[]>.
# MyApp.yaml
View::JSON:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/View/Template/PHP.pm view on Meta::CPAN
}
# set up PHP module callbacks
my $OUTPUT = '';
PHP::options( stdout => sub { $OUTPUT .= $_[0] } );
PHP::options( stderr => sub { $self->handle_warning($c, $_[0]) } );
PHP::options( header => sub { $self->header_callback($c, $_[0], $_[1]) } );
$self->{_headers} = [];
view all matches for this distribution
view release on metacpan or search on metacpan
0.006 31 August 2016
- Update version of Template::Pure to close known bugs
- use weaken in a few places to solve circular references
- pass the view object to the pure object so that we can use it in
pure callbacks.
- Start on new ::Helpers package with first Helper 'Uri' for generating
correct URIs.
0.005 28 August 2016
- Update version of Template::Pure to close known bugs
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CatalystX/CRUD/YUI/TT/static/js/crud.js view on Meta::CPAN
// global var trackers
YAHOO.crud.TABS = [];
YAHOO.crud.HISTORY = [];
// set global array of callbacks to execute on form submit
YAHOO.crud.onFormSubmit = [];
/* use FireBug for debugging if it is available */
if (!YAHOO.crud.log) {
view all matches for this distribution
view release on metacpan or search on metacpan
root/static/js/yui/build/autocomplete/autocomplete-min.js view on Meta::CPAN
YAHOO.widget.AutoComplete=function(G,B,J,C){if(G&&B&&J){if(J instanceof YAHOO.widget.DataSource){this.dataSource=J;}else{return ;}if(YAHOO.util.Dom.inDocument(G)){if(YAHOO.lang.isString(G)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "...
YAHOO.util.Event.purgeElement(D,true);D.innerHTML="";for(var C in this){if(YAHOO.lang.hasOwnProperty(this,C)){this[C]=null;}}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.w...
}}if(C[B]==" "){for(var A=C.length-1;A>=0;A--){if(G[E-1]==C[A]){E--;break;}}}if(E>-1){var D=E+1;while(G.charAt(D)==" "){D+=1;}this._sSavedQuery=G.substring(0,D);G=G.substr(D);}else{if(G.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}}if((G&&(...
this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);}else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(G){if(t...
YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.D...
}else{sValue="";}}aFieldSet.unshift(sValue);}aResults.unshift(aFieldSet);}break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse...
view all matches for this distribution
view release on metacpan or search on metacpan
- Adding support for default XML::Struct parsing
- Adding support for passing handlers by name and by invocation
- Refactoring the RAW XML response into the Catmandu::Importer::OAI::RAW parser
0.04 2014-06-15 20:30:07 CEST
- switched to the new HTTP::OAI with callbacks
- adding a network test
0.03 2014-06-15 10:22:55 CEST
- new option: dry (as supported my Catmandu::Importer::getJSON)
- new option: listIdentifiers
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Store/Solr/CQL.pm view on Meta::CPAN
$term = lc $term;
}
}
}
#change term using callbacks
if (ref $op && $op->{cb}) {
my ($pkg, $sub) = @{$op->{cb}};
$self->log->debug(
"term '$term' changed to ${pkg}->${sub}");
$term = require_package($pkg)->$sub($term);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Store/MongoDB/CQL.pm view on Meta::CPAN
$term = lc $term;
}
}
}
#change term using callbacks
if (ref $op && $op->{cb}) {
my ($pkg, $sub) = @{$op->{cb}};
$term = require_package($pkg)->$sub($term);
}
elsif ($q_mapping->{cb}) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Centrifugo/Client.pm view on Meta::CPAN
# This function is called when client is connected to the WebSocket
sub _on_ws_connect {
my ($this) = @_;
$this->_debug( "Centrifugo::Client : WebSocket connected to $this->{WS_URL}" );
# define the callbacks
$this->{WSHANDLE}->on(each_message => sub { $this->_on_ws_message($_[1]) });
$this->{WSHANDLE}->on(finish => sub { $this->_on_close(($_[0])->close_reason()) });
$this->{WSHANDLE}->on(parse_error => sub {
my($cnx, $error) = @_;
$this->_debug( "Error in Centrifugo::Client : $error" );
view all matches for this distribution
view release on metacpan or search on metacpan
examples/bridge_extension_example.pl view on Meta::CPAN
window.chandra.invoke('task_done', [id]);
}
};
JS
# ââ 4. Perl-side callbacks ââââââââââââââââââââââââââââââââââââââââââ
my %tasks;
$app->bind('task_added', sub {
my ($id, $text) = @_;
$tasks{$id} = { text => $text, done => 0 };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Changes.pm view on Meta::CPAN
return( $self );
}
sub preamble { return( shift->_set_get_scalar_as_object({
field => 'preamble',
callbacks =>
{
set => sub
{
my( $self, $text ) = @_;
if( defined( $text ) && $text->defined )
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Char/Replace.pm view on Meta::CPAN
=item undef â keeps the original character unchanged
=item a code ref â called with the character as argument; return value is the replacement
(return undef to keep original, empty string to delete)
B<Note:> Code ref callbacks are significantly slower than static replacements due to
function call overhead. Avoid heavy computation inside callbacks. Callbacks receive
a single-character string argument; for tainted input, the output string inherits the
taint flag from the input (not from the callback return value).
=back
lib/Char/Replace.pm view on Meta::CPAN
=item undef â keeps the original character unchanged
=back
Multi-character strings, empty strings (deletion), and code refs will cause a croak.
Use C<replace()> when you need expansion, deletion, or dynamic callbacks.
my $map = Char::Replace::identity_map();
$map->[ ord('a') ] = 'A';
my $str = "abcabc";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chart/GGPlot/Setup.pm view on Meta::CPAN
min_level => 'debug',
newline => 1,
stderr => 1,
]
],
callbacks => sub {
my %params = @_;
my $msg = $params{message};
my $level = uc($params{level});
return sprintf("%s [Chart::GGPlot $level] %s", strftime('%Y-%m-%d %H:%M:%S', localtime(time)), $msg);
},
view all matches for this distribution
view release on metacpan or search on metacpan
share/plotly.js/plotly.min.js view on Meta::CPAN
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
"use strict";var e=t("base64-js"),n=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;function i(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=ne...
/*! Native Promise Only
v0.8.1 (c) Kyle Simpson
MIT License: http://getify.mit-license.org
*/
!function(t,r,n){r[t]=r[t]||n(),void 0!==e&&e.exports&&(e.exports=r[t])}("Promise",void 0!==t?t:this,(function(){"use strict";var t,e,n,i=Object.prototype.toString,a=void 0!==r?function(t){return r(t)}:setTimeout;try{Object.defineProperty({},"x",{}),...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chess/GameClock/GclkCounter.pm view on Meta::CPAN
$whites=GclkCounter->new ;
$whites->init($arg,$color) ;
$whites-> cntupdate{$timestamp);
$whites->print ;
# the functions hereafter are only used inside callbacks
&start($whites,$blacks,$mainwindow,$white_move_button,$black_move_button)= ;
&stop($halt_button,$whites,$blacks) ;
&capture($mouse_event,$whites,$blacks ) ;
=head1 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chess4p/Pgn/Reader.pm view on Meta::CPAN
=item begin_game($visitor)
This will be called when the reader has determined that another game is available to be read.
Use this for cleaning up from any previous games read.
Return 0 to have the reader call the other callbacks as this game is read.
Return 1 to have the reader skip the game by not calling the other callbacks as this game is read.
=item end_game($visitor)
This is called immediately before the reader returns.
lib/Chess4p/Pgn/Reader.pm view on Meta::CPAN
=item end_headers($visitor)
Called when the reader has determined that there are no more headers to be read.
Return 0 to have the reader call the other callbacks as it reads the movetext section.
Return 1 to have the reader skip the movetext section of this game. This is useful in searching for specific
header values like player names, etc.
=item visit_comment($visitor, $comment)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chouette.pm view on Meta::CPAN
=item L<Callback::Frame>
Makes exception handling simple and convenient. You can C<die> anywhere and it will only affect the request being currently handled.
Important note: If you are using 3rd-party libraries that accept callbacks, please understand how L<Callback::Frame> works. You will usually need to pass C<fub {}> instead of C<sub {}> to these libraries. See the L<EXCEPTIONS> section for more detail...
=item L<Session::Token>
For random identifiers such as session tokens (obviously).
lib/Chouette.pm view on Meta::CPAN
If you want a config file, this path is where it will be read from. The file's format is L<YAML>. The values in this file over-ride the values in C<config_defaults>. If this parameter is not provided then it will not attempt to load a config file and...
=item C<routes>
Routes are specified as a hash-ref of route paths, mapping to hash-refs of methods, mapping to package+function names or callbacks. For example:
routes => {
'/myapi/resource' => {
POST => 'MyAPI::Resource::create',
GET => 'MyAPI::Resource::get_all',
lib/Chouette.pm view on Meta::CPAN
$c->done;
You will need to send a response later, usually from an async callback. Note: If the last reference to the context is destroyed without a response being sent, the message C<no response was sent, sending 500> will be logged and a 500 "internal server ...
You don't ever need to call C<done>. You can just C<return> from the handler instead. C<done> is only for convenience in case you are deeply nested in callbacks and don't want to worry about writing a bunch of nested returns.
=item C<respond_raw>
Similar to C<respond> except it doesn't assume JSON encoding:
lib/Chouette.pm view on Meta::CPAN
} else {
# failure. error message is in $@
}
});
Even if C<exec> failed, the callback still gets called. Whether or not it succeeded is indicated by its parameters. You can think of this as a sort of "in-band" signalling. The fact that there was an error, and what exactly that error was, needs to b...
But with both of these methods, what should the callback do when it is notified of an error? It can't just C<die> because nothing will catch the exception. With the L<EV> event loop you will see this:
EV: error in callback (ignoring): failure: ERROR: relation "no_such_table" does not exist
lib/Chouette.pm view on Meta::CPAN
Perhaps most importantly, if some unexpected exception is thrown by your callback (or something that it calls) then the event loop will receive an exception and nothing will get logged or replied to.
=back
For these reasons, Chouette uses L<Callback::Frame> to deal with exceptions. The idea is that the exception handling code is carried around with your callbacks. For instance, this is how you would accomplish the same thing with Chouette:
my $dbh = $c->task('db');
$dbh->selectrow_arrayref("SELECT * FROM no_such_table", undef, sub {
my ($dbh, $rows) = @_;
lib/Chouette.pm view on Meta::CPAN
# Even if I can die here and it will get routed to the right request!
});
The callback will only be invoked in the success case. If a failure occurs, an exception will be raised in the dynamic scope that was in effect when the callback was installed. Because Chouette installs a C<catch> handler for each request, an appropr...
Important note: Libraries like L<AnyEvent::Task> (which is what C<task> in the above example uses) are L<Callback::Frame>-aware. This means that you can pass C<sub {}> callbacks into them and they will automatically convert them to C<fub {}> callback...
When using 3rd-party libraries, you must pass C<fub {}> instead. Also, you'll need to figure out how the library handles error cases, and throw exceptions as appropriate. For example, if you really wanted to use L<AnyEvent::DBI> (even though the L<An...
$dbh->exec("SELECT * FROM no_such_table", fub {
my ($dbh, $rows, $rv) = @_;
lib/Chouette.pm view on Meta::CPAN
# success
});
Note that the C<sub> has been changed to C<fub> and an exception is thrown for the error case.
In summary, when installing callbacks you must use C<fub> except when the library is L<Callback::Frame>-aware.
Please see the L<Callback::Frame> documentation for more specifics.
=head2 CONTROL FLOW
view all matches for this distribution
view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Accessor/Inherited/XS.pm view on Meta::CPAN
use Class::Accessor::Inherited::XS {
inherited => ['foo'],
inherited_cb => ['bar'],
};
You can register new inherited accessor types with associated read/write callbacks. Unlike
L<Class::Accessor::Grouped>, only a single callback can be set for a type, without per-class
B<get_$type>/B<set_$type> lookups. You can omit either B<on_read> or B<on_write> if you don't
need it to avoid performance losses from associated call.
B<on_read> callback receives a single argument - return value from the underlying B<inherited> accessor. It's result
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Anonymous.pm view on Meta::CPAN
my $subclass = extend $class, sub { my ($self) = @_; ... };
Define a new subclass of an existing anonymous class.
Takes an existing class and a code reference which will be called after the parent class builder callback(s).
Note that all callbacks receive the same arguments, so you might want to plan for that.
=head2 via
my $subclass = extend $class, via { my ($self) = @_; ... };
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Autouse.pm view on Meta::CPAN
}
sub _try_loaders {
_debug(\@_, 0) if DEBUG;
my ($class, $function, @optional_args) = @_;
# The function and args are only present to help callbacks whose main goal is to
# do "syntactic sugar" instead of really writing a class
# This allows us to shortcut out of re-checking a class
$TRIED_CLASS{$class}++;
lib/Class/Autouse.pm view on Meta::CPAN
several ways to do this in Perl. Strategies which require overriding
UNIVERSAL::AUTOLOAD can use this interface instead to share that method
with the superloader, and with class gnerators.
When Perl is unable to find a subroutine/method, and all of the class loaders
are exhausted, callbacks registered via sugar() are called. The callbacks
recieve the class name, method name, and parameters of the call.
If the callback returns nothing, Class::Autouse will continue to iterate through
other callbacks. The first callback which returns a true value will
end iteration. That value is expected to be a CODE reference which will respond
to the AUTOLOAD call.
Note: The sugar callback(s) will only be fired by UNIVERSAL::AUTOLOAD after all
other attempts at loading the class are done, and after attempts to use regular
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Test/Harness.pm view on Meta::CPAN
Remember exit code
Completely redo the print summary code.
Implement Straps callbacks. (experimentally implemented)
Straps->analyze_file() not taint clean, don't know if it can be
Fix that damned VMS nit.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Data/Annotated.pm view on Meta::CPAN
my $$obj = Class::Data::Annotated->new();
=cut
our $VERSION = '0.2';
my $callbacks = {
key_does_not_exist => sub {},
index_does_not_exist => sub {},
retrieve_index_from_non_array => sub {},
retrieve_key_from_non_hash => sub {},
};
lib/Class/Data/Annotated.pm view on Meta::CPAN
=cut
sub new {
my ($class, $struct) = @_;
croak('I just gotta have data') unless $struct;
return bless {Annotations => Data::Annotated->new(), Data => Data::Path->new($struct, $callbacks)}, $class;
}
=head2 annotate($path, \%annotation)
annotate a peice of the data. if that piece does not exist it will return undef. Otherwise it returns the data annotated.
view all matches for this distribution
view release on metacpan or search on metacpan
0.14 Thu Mar 16 23:07:22 EST 2006
- Fixed test bug where thread test wouldn't properly skip for Win32 Perl
5.6 (with ithreads enabled for pseudofork but no threads.pm)
- Improved handling of "die" in set_hook and get_hook callbacks
0.13 Fri Mar 10 10:32:08 EST 2006
- Test for Scalar::Util::weaken fallback had a bug that would fail on
Perl versions prior to 5.6. Fixed to be fully backwards compatible.
view all matches for this distribution