Re: Perl Auto-RPC

2001-03-29 Thread Nathan Torkington

Simon Wistow wrote:

 You use the RPC::Automagic module and pass it a RPC server/port/user
 name/password/whatever. From that point on it overloads the use keyword
 and anything you try and use it will actually connect to the RPC server
 and pass it all the parameters. Any modules you didn't want froma
 remote server you just use them before you use the RPC module. Or tell
 it to ignore those.

That's kinda, but not quite, what SOAP::Lite has.  For a single
namespace you can tell SOAP::Lite that function calls are really
SOAP calls.  It's all invisible, and really cool.

If you whispered this idea into Paul Kulchenko's ear, he'd probably
have it implemented within a day :-)

Nat



Re: Perl Auto-RPC

2001-03-29 Thread Nathan Torkington

Greg McCarroll wrote:
 sure it makes sense, but it still is CiP and trust me this isn't
 the only bit of CiP in here and much kudos to Paul for it ;-)

I'm unsure what CiP is, but if it has anything to do with gnarliness,
I know that Paul wrote a 1k regexp to parse XML correctly.  It only
fails one test from a real XML parsing package, and he tracked that
to the limitations of the new RE stuff in 5.6.0.

That dropped my jaw.

Nat



Re: Perl Auto-RPC

2001-03-29 Thread Greg McCarroll

* Nathan Torkington ([EMAIL PROTECTED]) wrote:
 Greg McCarroll wrote:
  sure it makes sense, but it still is CiP and trust me this isn't
  the only bit of CiP in here and much kudos to Paul for it ;-)
 
 I'm unsure what CiP is, but if it has anything to do with gnarliness,

CiP = Crack induced Perl, the sort of things that most C++ _software
  engineers_ would want you strung up for. The sort of things
  you can only get away with in languages like Perl and previously
  the only other sort of place you could see this sort of thing
  was Assembly and/or severe wizardry C.

 I know that Paul wrote a 1k regexp to parse XML correctly.  It only
 fails one test from a real XML parsing package, and he tracked that
 to the limitations of the new RE stuff in 5.6.0.
 
 That dropped my jaw.

Is it available online?

Greg

-- 
Greg McCarroll  http://www.mccarroll.uklinux.net



Re: Perl Auto-RPC

2001-03-29 Thread pmh

On Thu, 29 Mar 2001 00:37:38 -0800, Nathan Torkington wrote:
 Greg McCarroll wrote:
  sure it makes sense, but it still is CiP and trust me this isn't
  the only bit of CiP in here and much kudos to Paul for it ;-)
 
 I'm unsure what CiP is, but if it has anything to do with gnarliness,
 I know that Paul wrote a 1k regexp to parse XML correctly.  It only
 fails one test from a real XML parsing package, and he tracked that
 to the limitations of the new RE stuff in 5.6.0.

Here's what I use, which probably isn't what most people would think of when they hear 
"XML parser", but it does let me extract the bits I generally want. I wouldn't give 
this a CiP rating, but then I know how it works.

# xml_parse($xml,$tag)
# Return the contents of any $tags appearing in $xml
# Returns an arrayref of hashrefs of attributes, content in {__content__}
# If $tag eq '*', returns all tags, element names in {__element__}
# This is pretty simple, and assumes the following:
#attributes match \w+
#all attributes have double-quoted values
#there are no CDATA[[]] sections
#end tags don't have attributes
#$xml is otherwise well-formed
sub xml_parse{
  my($xml,$_tag)=@_;
  my $tag=$_tag eq '*' ? '[\w:-]+' : "\Q$_tag\E";

  # Remove comments
  $xml=~s/!--.*?--//gs;

  # Extract tags
  my @tags;
  pos $xml=0; # Reset /g position
  while($xml=~m#\G.*?($tag)\b#gs){
my $tag=$1;
my %tag;
$tag{__element__}=$tag if $_tag eq '*';

while($xml=~m#\G\s+(\w+)="([^"]*)"#gc){
  $tag{$1}=$2;
}
if($xml=~m#\G\s*/#gc){
  # There's no content
}else{
  # Get the content
  $xml=~m#\G\s*#gc or next; # Next means not well formed
  my $level=1;
  while(1){
if($xml=~m#\G((?:(?!/?\s*\Q$tag\E\b).)+)#gcs){
  # More content
  $tag{__content__}.=$1;
}elsif($xml=~m#\G(/\s*\Q$tag\E\s*)#gc){
  # End tag
  if(--$level){
$tag{__content__}.=$1;
  }else{
last;
  }
}elsif($xml=~m#\G(\s*\Q$tag\E\b([^]*))#gc){
  # Start tag
  $tag{__content__}.=$1;
  ++$level unless (my $tmp=$2)=~m#/\s*$#;
}else{
  # We must have reached the end of the string, so it's not well formed
  last;
}
  }
}
push @tags,\%tag;
  }

  \@tags;
}


-- 
Peter Haworth   [EMAIL PROTECTED]
 "I think there's a problem with the server power supply"
 "Why?"
 "There were flames coming out of the cooling fan until it stopped."



Re: Perl Auto-RPC

2001-03-29 Thread Leon Brocard

[EMAIL PROTECTED] sent the following bits through the ether:

 Here's what I use, which probably isn't what most people would think
 of when they hear "XML parser"

Indeed. This is because it doesn't parse XML.

Leon
-- 
Leon Brocard.http://www.astray.com/
yapc::Europehttp://yapc.org/Europe/

... The worst thing about censorship is XX 



Re: Perl Auto-RPC

2001-03-28 Thread Simon Wistow

Greg McCarroll wrote:
 
 # locally an rpc call is made to the remote package server, which creates
 # an object and returns the local id to the other machine

That was the way I was thinking of doing it as well.

Hmm, nother thing to add to the list of things to do.



Re: Perl Auto-RPC

2001-03-28 Thread Simon Wistow

Robin Houston wrote:

 A stateful server would definitely help here.

It was going to be a stateful server. But stateless could be an option.



Re: Perl Auto-RPC

2001-03-28 Thread Robin Houston

Is the intention simply that it be possible to use modules
which aren't available locally?

If so, you could do something like:

 - use request is passed to module server
 - module server "require"s module (will do nothing if it's already
been required. That's a good thing)
 - server serialises module stash (including subs) and passes it
   back to client
 - client deserialises stash, calls import()
 - client can now use module without actually having it.

Major problems:

 1. (de)serialisation would be hard, but not impossible
(the hard bit, code, can be done with B::Deparse)
 2. XS won't work


(2) is the killer, I fear.

 .robin.



Re: Perl Auto-RPC

2001-03-28 Thread Mark Fowler

Code I wrote to do most of what you people are talking about a couple of
weeks back, loading over ssh.

This does not work for non-pure perl code.  i.e. XS is a no-no

The idea I was using it for:

 a) User presses a button in the web browser
 b) Downloads .config.html from that directory the site which contains 

i)  The current directory from the server's point of view
ii) The address of the perl code to configure this site

Both of which have RC5 checksums

 c) The perl code is downloaded to configure said site and run  This
starts a Tk widget that can be used to edit config stuff remotely.

The key idea behind this is that you need nothing special on the server
bar ssh and httpd.  And your client need have no special idea of what
it needs to have installed.

Anyway, the code:

use File::Remote;

# then later

 
# Setting up the @INC trap


# right now we modify @INC so that it will load files from afar
# this stolen from p5p - http://www.perl.com/pub/2001/03/
# p5pdigest/THISWEEK-20010305.html

push @INC, sub 
{
my $foo = shift;
my $modname = shift;
  
# this is going through scp - make all :: into /
$modname =~ s|::|/|;

# combine the paths
my $filename = $codepath.$modname;

# create a $remote object
my $remote = File::Remote-new( rsh = '/usr/bin/ssh',
   rcp = '/usr/bin/scp',); 

my $fh = new IO::Handle;

# open the thingy as if by magic, returning
# undef if there is a problem
$remote-open($fh, $filename) or return undef;

return $fh;
   }


-- 
print "\n",map{my$a="\n"if(length$_6);' 'x(36-length($_)/2)."$_\n$a"} (
   Name  = 'Mark Fowler',Title = 'Technology Developer'  ,
   Firm  = 'Profero Ltd',Web   = 'http://www.profero.com/'   ,
   Email = '[EMAIL PROTECTED]',   Phone = '+44 (0) 20 7700 9960'  )