Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 20193
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: mark [...] summersault.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: PATCH: let get() work as a class method
Download (untitled) / with headers
text/plain 170b
The attached code/test/doc patch simplies this idiom: my $mech = WWW::Mechanize->new(); $mech->get($uri); To just: my $mech = WWW::Mechanize->get($uri); Mark
Subject: mech_get.diff
Download mech_get.diff
text/x-diff 472b
297a298,299 > =head2 $mech = WWW::Mechanize->get( $url ) > 303a306,308 > If called as a class method, it's the same as first calling C<new()> with > no arguments. > 319c324 < my $self = shift; --- > my $self_or_class = shift; 320a326,336 > > my $self; > my $already_obj = (ref $self_or_class); > if ($already_obj) { > $self = $self_or_class; > } > else { > my $class = $self_or_class; > $self = $class->new(); > } >
Subject: get.t
Download get.t
text/x-perl 340b
#!perl -Tw use warnings; use strict; use URI::file; use Test::More 'no_plan'; BEGIN { use_ok('WWW::Mechanize'); } my $uri = URI::file->new_abs( "t/image-parse.html" )->as_string; my $mech; eval { $mech = WWW::Mechanize->get( $uri ); }; is($@,'','survived eval'); isa_ok( $mech, 'HTTP::Response', "get works as a class method" );
Subject: Re: [rt.cpan.org #20193] PATCH: let get() work as a class method
Date: Thu, 29 Jun 2006 14:23:04 -0500
To: bug-WWW-Mechanize [...] rt.cpan.org
From: Andy Lester <andy [...] petdance.com>
Download (untitled) / with headers
text/plain 335b
Show quoted text
> > my $mech = WWW::Mechanize->new(); > $mech->get($uri); > > To just: > > my $mech = WWW::Mechanize->get($uri);
Very interesting, but, I would prefer: my $mech = WWW::Mechanize->new( get => $uri ); That way you can still pass stuff to the constructor. -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
Subject: Re: [rt.cpan.org #20193] PATCH: let get() work as a class method
Date: Thu, 29 Jun 2006 16:02:33 -0400
To: bug-WWW-Mechanize [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Download (untitled) / with headers
text/plain 744b
andy@petdance.com via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=20193 > > >
>> my $mech = WWW::Mechanize->new(); >> $mech->get($uri); >> >> To just: >> >> my $mech = WWW::Mechanize->get($uri); >>
> > Very interesting, but, I would prefer: > > my $mech = WWW::Mechanize->new( get => $uri ); >
Thanks for the feedback Andy. I thought of that, but I wanted to make something super-simple for the common case. For the less common case of passing args to new(), you can still call new() before get(). If people are always passing the same args to new() all the time, hopefully they've subclassed or found some other solution to that annoyance. So I still prefer the original get-as-class-method proposal Mark
Subject: Re: [rt.cpan.org #20193] PATCH: let get() work as a class method
Date: Thu, 29 Jun 2006 15:08:51 -0500
To: bug-WWW-Mechanize [...] rt.cpan.org
From: Andy Lester <andy [...] petdance.com>
Download (untitled) / with headers
text/plain 365b
On Jun 29, 2006, at 3:04 PM, mark@summersault.com via RT wrote: Show quoted text
> So I still prefer the original get-as-class-method proposal
Wait, we have another showstopper. get() returns an HTTP::Response. I don't want it to sometimes do HTTP::Response and sometimes WWW::Mechanize objects. -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
Subject: Re: [rt.cpan.org #20193] PATCH: let get() work as a class method
Date: Thu, 29 Jun 2006 16:21:49 -0400
To: bug-WWW-Mechanize [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Download (untitled) / with headers
text/plain 478b
andy@petdance.com via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=20193 > > > > On Jun 29, 2006, at 3:04 PM, mark@summersault.com via RT wrote: > >
>> So I still prefer the original get-as-class-method proposal >>
> > Wait, we have another showstopper. > > get() returns an HTTP::Response. I don't want it to sometimes do > HTTP::Response and sometimes WWW::Mechanize objects. >
Good point. I agree. Let's back the truck up on this idea. Mark


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.