Acme-RPC
view release on metacpan or search on metacpan
author:
- Scott Walters <scott@slowass.net>
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
requires:
Continuity: 0
Devel::Caller: 0
IO::Handle: 0
JSON: 0
PadWalker: 0
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.48
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Makefile.PL view on Meta::CPAN
use 5.008000;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Acme::RPC',
VERSION_FROM => 'lib/Acme/RPC.pm', # finds $VERSION
PREREQ_PM => {
Continuity => 0.0,
'IO::Handle' => 0.0,
JSON => 0.0,
'Devel::Caller' => 0.0,
PadWalker => 0.0,
}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Acme/RPC.pm', # retrieve abstract from module
AUTHOR => 'Scott Walters <scott@slowass.net>') : ()),
);
lib/Acme/RPC.pm view on Meta::CPAN
use strict;
use warnings;
our $VERSION = '0.01';
use B;
use B::Deparse;
use Continuity;
use IO::Handle;
# use Devel::Pointer;
use JSON;
use Data::Dumper;
use Devel::Caller 'caller_cv';
use PadWalker 'peek_sub';
use Scalar::Util 'blessed';
my $comment = <<'EOF';
Todo:
* Accept JSON as input too, for the parameters!
* When taking apart CODE, do closes_over() too, not just peek_my().
* Weaken references held in %registry.
* Bug: Second hit with an oid= finds the server not accepting.
* Optionally require a password... use Acme::RPC password => whatever;
* entersubs=1, enterpackages=1, etc args to control how far the recurse goes in building $tree.
* Maybe don't recurse into blessed objects, but dump them nicely upon request.
Or maybe do recurse into them and dump their instance data.
If $oid is passed then recurse into arrays, hashes, and object instance data.
* We don't dump references found inside CODE in the main view.
But if they request a dump for that object, dump it.
Likewise, we're not dumping arrays and hashes, but if they request a dump on it, dump it.
* JSON output on the default tree view too.
We'd have to sanitize our tree...
* Document that people need to use Event::loop or something; an Acme module to insert calls to cede would be awesome for this
* Package names like foo:: should be hyperlinked too; should be able call ?oid=whatever&action=new&args=whatever on them
* The whole tree() recurse thing if it gets any more complicated is going to need a %seen list to avoid infinite recursion.
Think About:
lib/Acme/RPC.pm view on Meta::CPAN
* lazy=1 parameter where the last $tree is re-used rather than re-computed.
* Should switch to our own recurse logic from Data::Dumper to support these other things.
* action=dump on anything; in the case of a coderef, find its source on disc or else deparse it
* action=call on coderefs and blessed objects, with an args parameter, or arg1, arg2, arg3, etc, and a method parameter for blessed objs.
* json will croak if a reference contains objects in side it somewhere. Should handle this gracefully.
* Offer JSON output! Not just Data::Dumper. Do this for action=dump, action=call, and the default tree view.
* If Devel::Leak won't give us refs... have to do an Acme::State style crawl from main::,
but crawling into each sub and looking at its lexicals with PadWalker.
Could make for a nice tree view.
Would also make it easy to filter out the variables that hold refs.
* Maybe this should be called Acme::RPC.
* Actually crawl into code refs when recursing the output!
lib/Acme/RPC.pm view on Meta::CPAN
sub tryunobject {
my $ob = shift;
my $request = shift;
if( blessed($ob) and UNIVERSAL::isa($ob, 'HASH') ) {
$ob = { %$ob };
} elsif( blessed($ob) and UNIVERSAL::isa($ob, 'ARRAY') ) {
$ob = [ @$ob ];
} elsif( blessed($ob) and UNIVERSAL::isa($ob, 'SCALAR') ) {
$ob = \ ${$ob};
} elsif( blessed($ob) ) {
$request->print("object not blessed hash, array or scalar... no logic for converting to JSON, sorry");
return;
}
return $ob;
}
END { $continuity->loop }
1;
lib/Acme/RPC.pm view on Meta::CPAN
=item C<< / >>
(No parameter.)
=item C<< action=dump >>
Gives an index of packages, subroutines, variables in those subroutines, closures in those variables, and so on.
=item C<< output=json >>
Output a JavaScript datastructures (JSON) instead of Perl style L<Data::Dumper> or HTML.
The main index page otherwise prints out HTML (under the assumption that a human will be digging through it)
and other things mostly emit L<Data::Dumper> formatted text.
=item C<< oid=(number) >>
=item C<< path=/path/to/something >>
There are two ways to specify or reference an object: by it's C<oid> or by the path to navigate to it from the
main index screen.
JSON and HTML output from the main index screen specifies the oids of each item and the paths can be derived from
the labels in the graph.
With no action specified, it defaults to C<dump>.
=item C<< action=call >>
Invokes a method or code ref.
It does I<not> invoke object references.
Requires either C<oid> or C<path> be specified.
You may also set C<arg0>, C<arg1>, C<arg2> etc GET or POST parameters to pass data into the function.
There's currently no way to pass in an arbitrary object (see TODO below).
lib/Acme/RPC.pm view on Meta::CPAN
As above, takes argument data from C<arg0>, C<arg1>, C<arg2>, etc.
=item C<< lazy=1 >>
Avoid rebuilding the entire object graph to speed things up a bit.
=head2 TODO
C<oidarg[n]> to pass in an arbitrary other object as a parameter.
JSON posted to the server to specify arguments.
JSON posted to the server to specify the entire function/method call.
=head2 BUGS
There is no security. At all.
A lot of this stuff hasn't been tested. At all.
You will leak memory like crazy.
Really, I wasted about three days on this, so I'm very much in a "it compiles, ship it!" mode.
( run in 0.895 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )