Skip Menu |

This queue is for tickets about the MooseX-Storage CPAN distribution.

Report information
The Basics
Id: 70278
Status: stalled
Priority: 0/
Queue: MooseX-Storage

People
Owner: Nobody in particular
Requestors: icydee [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.30
Fixed in: (no value)



Subject: Class Bar is not loaded, cannot unpack.
I have a data structure similar to the following. package Foo; use Moose; use MooseX::Storage; has 'bar' => (is => 'rw', isa => 'Bar'); 1; package Bar; use Moose; use MooseX::Storage; has 'thingy' => (is => 'rw', isa 'Int'); 1; when unpacking the data, the second level 'Bar' object is not unpacked, it generates an error. 'Class Bar is not loaded, cannot unpack' This is because I have not 'use'd or 'require'd the class in my code, but doing so is very inconvenient since I would need to know in advance what all the possible class names are which, because I am creating the classes using a Plugin system, I don't. My (possibly over-simplistic) solution is to add the following line in MooseX::Storage::Engine 167: eval "require $class"; 168: my $meta = eval { $class->meta }; I can't see any reason not to do this but perhaps you can see a better solution? Regards Ian
On Mon Aug 15 11:11:56 2011, ICYDEE wrote: Show quoted text
> This is because I have not 'use'd or 'require'd the class in my code, > but doing so is very inconvenient since I would need to know in advance > what all the possible class names are which, because I am creating the > classes using a Plugin system, I don't.
Why not just load all the possible plugins in advance? I.e. useall from Module::Find or similar? Show quoted text
> My (possibly over-simplistic) solution is to add the following line in > MooseX::Storage::Engine > > 167: eval "require $class"; > 168: my $meta = eval { $class->meta }; > > I can't see any reason not to do this but perhaps you can see a better > solution?
I can see lots of reasons not to do this. There are a number of situations where I am unserializing semi-trusted data, and I don't want this to cause arbitrary code to be loaded. I would however be happy with a patch which _optionally_ loaded the classes needed.