McDarren has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,

Update: This has been solved. Please see reply from syphilis below (thanks Rob) :)

Our company has recently switched to Gmail, and we've been using the VUser::Google::ProvisioningAPI::V2_0 module for provisioning users and lists, etc.

All has been going well until today, when I tried to use the RetrievePageOfEmailLists() method.

The best way to demonstrate my problem is by example, so please consider the following:

#!/usr/bin/perl -l use strict; use warnings; use Data::Dumper::Simple; use VUser::Google::ProvisioningAPI::V2_0; BEGIN { for (keys %INC) { print "$_ => $INC{$_}" if $_ =~ /Google/; } } require 'gmail-tools.pl'; my $config_file = 'gmail.cfg'; my $config = get_credentials($config_file); my $gmail = new VUser::Google::ProvisioningAPI($config->{domain}, $con +fig->{user}, $config->{pass}, '2.0'); $gmail->RetrievePageOfEmailLists('.'); print Dumper($gmail->{result}) and exit;
The above code produces the following output:
VUser/Google/ProvisioningAPI/V2_0.pm => /usr/local/share/perl/5.8.8/VU +ser/Google/ProvisioningAPI/V2_0.pm VUser/Google/ProvisioningAPI.pm => /usr/local/share/perl/5.8.8/VUser/G +oogle/ProvisioningAPI.pm Can't locate object method "RetrievePageOfEmailLists" via package "VUs +er::Google::ProvisioningAPI::V2_0" at ./test.pl line 20.
I can't for the life of me figure out why the method isn't located.
RetrievePageOfEmailLists() is a method that was added in V2 of the module. I've checked the source, and it is definitely there. The only thing I can come up with is that it's failing because it doesn't exist in ProvisioningAPI.pm. But that doesn't make sense, as I've used other V2 specific methods (eg. RetrievePageOfRecipients()), which have all worked fine.

I'm hopeful that I'm missing something obvious - can anyone tell me what that something is?

Thanks,
Darren :)

Replies are listed 'Best First'.
Re: Google Provisioning API - method not found
by syphilis (Archbishop) on Jul 23, 2008 at 12:58 UTC
    I think it's just malformed pod - the doubling up of "=cut" effectively hiding the sub from view:
    =cut =cut sub RetrievePageOfEmailLists { . .
    Cheers,
    Rob
      Yes, you are absolutely right.
      I had missed that earlier, but when I went back and had another look at the module source (after posting my question *sigh*), I also noticed it.
      Getting rid of that fixes the problem.

      Cheers,
      Darren :)

        Life would be so much simpler if people would refrain from intermingling code and pod :-)

        Cheers,
        Rob
      As an aside, I today discovered another bug associated with that same module routine (after an hour or so of hair-pulling).

      The line my $start_emaillist; should be my $start_emaillist = shift;

      The effect of it not being so (pretty obvious) is that any parameter passed to the method is ignored, and the result set always starts from the first list, no matter where you ask it to start.

      I've informed the module author of both problems, hopefully he'll fix it :)

Re: Google Provisioning API - method not found
by Corion (Patriarch) on Jul 23, 2008 at 12:54 UTC

    From a short look at the code, it seems that VUser::Google::ProvisioningAPI is a factory for either VUser::Google::ProvisioningAPI::V1_0 or VUser::Google::ProvisioningAPI::V2_0 objects. You could try to find out what kind of object you got back by printing ref:

    print ref $gmail;

    Maybe you have an older version of the module loaded?

    print $VUser::Google::ProvisioningAPI::VERSION; require VUser::Google::ProvisioningAPI::V2_0; print $VUser::Google::ProvisioningAPI::V2_0::VERSION;
      print ref $gmail;
      gives me...
      VUser::Google::ProvisioningAPI::V2_0
      BUT..... I think I just figured it out myself.
      I had a closer look at the module source, and this is what it looks like:
      =pod RetrievePageOfEmailLists($startList) =over Get a single page (100 lists) of email lists. =cut =cut sub RetrievePageOfEmailLists { my $self = shift; my $start_emaillist; my $url = GOOGLEBASEURL.$self->{domain}."/emailList/$APIVersion"; if ($start_emaillist) { $url .= "?startEmailListName=$start_emaillist"; } my @entries = (); if ($self->Request('GET', $url)) { foreach my $entry (@{ $self->{result}{'entry'} }) { push @entries, $self->buildEmailListEntry($entry); } } else { return undef; } # Return list of EmailListEntries return @entries; }
      Notice that extra =cut in there?
      I tried commenting that out, and bingo!