Failed using with_map_records twice

43 views
Skip to first unread message

Olivier Salaün

unread,
Oct 18, 2012, 10:32:19 AM10/18/12
to rose-db...@googlegroups.com
Hi,

I use Rose-DB-Object version 0.795.

I have a strange behavior using the 'with_map_records' Rose::DB::Object::Manager option.

The objects I'm working with :
  • FederationRegistry::Data::Federation class
  • FederationRegistry::Data::Serviceprovider and FederationRegistry::Data::Identityprovider classes with many2many relation with FederationRegistry::Data::Federation

I need to access the mapping table because it contains usefull DB field.

I can run this code to browse identityproviders and their relations with federations:

   $idps = FederationRegistry::Data::Identityprovider::Manager->get_identityproviders(
    with_objects => ['federations'],
    with_map_records => 1,
    );
   
    foreach my $provider (@$idps) {
      foreach my $federation (@{$provider->federations}) {   
        printf "%s / %s / %s / %s\n", $provider->entityid, $federation->map_record()->status;
      }
    }

But if I try running the code below to browse serviceproviders afterward, it fails with this error message: "next() - Illegal map record argument: FederationRegistry::Data::ServiceproviderFederationMap=HASH(0xa4dddb4) at /usr/lib/perl5/site_perl/5.8.8/Rose/DB/Object/Manager.pm line 2284"

The second part of the code:
   $sps = FederationRegistry::Data::Serviceprovider::Manager->get_serviceproviders(
    with_objects => ['federations'],
    with_map_records => 1,
    );
   
    foreach my $provider (@$sps) {
      foreach my $federation (@{$provider->federations}) {   
        printf "%s / %s / %s / %s\n", $provider->entityid, $federation->map_record()->status;
      }
    }

I can run each of these pieces of code alone, but not within the same script.
Removing "with_map_records => 1," for the FederationRegistry::Data::Serviceprovider::Manager->get_serviceproviders() call removes the error, but then I can't access DB fileds of the mapping table.

Is there anything I do wrong?


Thanks for your help.


-- 
Olivier Salaün, pôle Services Applicatifs aux Utilisateurs
RENATER http://www.renater.fr
Tel : 02 23 23 71 27 

John Siracusa

unread,
Oct 18, 2012, 10:39:52 AM10/18/12
to rose-db...@googlegroups.com
On Thu, Oct 18, 2012 at 10:32 AM, Olivier Salaün
<olivier...@renater.fr> wrote:
> But if I try running the code below to browse serviceproviders afterward, it
> fails with this error message: "next() - Illegal map record argument:
> FederationRegistry::Data::ServiceproviderFederationMap=HASH(0xa4dddb4) at
> /usr/lib/perl5/site_perl/5.8.8/Rose/DB/Object/Manager.pm line 2284"

Try giving each map record method a different name (since they will
end up holding objects of different types). E.g., with_map_records =>
'some_method_name' instead of with_map_records => 1

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Manager.pm#with_map_records

-John

Olivier Salaün

unread,
Oct 18, 2012, 10:46:24 AM10/18/12
to rose-db...@googlegroups.com
Hi John,

Le 18/10/12 16:39, John Siracusa a �crit :
> On Thu, Oct 18, 2012 at 10:32 AM, Olivier Sala�n
It works much better when each call to Rose::DB::Object::Manager defines
a different method name associated to with_map_records.
Thanks a lot very the very quick response :)

--
Olivier Sala�n, p�le Services Applicatifs aux Utilisateurs
Reply all
Reply to author
Forward
0 new messages