Skip Menu |

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

Report information
The Basics
Id: 86415
Status: open
Priority: 0/
Queue: MooseX-Storage

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

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



Subject: MooseX::Storage::IO::StorableFile::store does not supports RegexpRef
Greetings, Please, add support to RegexpRef to MooseX::Storage since trying to serialize Moose objects that have attributes with RegexpRef type causes an exception. Here is a sample error message from a distribution that I'm developing (Siebel::Srvrmgr, available in CPAN). C:\Temp\perl\Siebel-Srvrmgr>prove -I C:\Temp\perl\Siebel-Srvrmgr\lib -I C:\Temp\perl\Siebel-Srvrmgr\t -v -m t\ActionListParams.t t\ActionListParams.t .. 1..22 ok 1 - use Siebel::Srvrmgr::Daemon::Action::ListParams; # # Test::Siebel::Srvrmgr::Daemon::Action::ListParams->class_attributes ok 2 - The object does has an attribute named parser ok 3 - The object does has an attribute named params # # Test::Siebel::Srvrmgr::Daemon::Action::ListParams->class_methods ok 4 - get_parser returns a Siebel::Srvrmgr::ListParser instance isa Siebel::Srvrmgr::ListParser ok 5 - Siebel::Srvrmgr::Daemon::Action::ListParams->can(...) not ok 6 - class_methods died (Cannot handle type constraint (RegexpRef) at C:/strawberry/perl/site/lib/MooseX/Storage/Engine.pm line 354, <DATA> line 1. # MooseX::Storage::Engine::find_type_handler('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::TypeConstraint=HASH(0x20712a4)', 'Regexp=REGEXP(0x27ce1f4)') called at C:/strawberry /perl/site/lib/MooseX/Storage/Engine.pm line 84 # MooseX::Storage::Engine::collapse_attribute_value('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::Attribute=HASH(0x2880844)', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/s ite/lib/MooseX/Storage/Engine.pm line 59 # MooseX::Storage::Engine::collapse_attribute('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::Attribute=HASH(0x2880844)', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/site/li b/MooseX/Storage/Engine.pm line 140 # MooseX::Storage::Engine::map_attributes('MooseX::Storage::Engine=HASH(0x27cc854)', 'collapse_attribute', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/site/lib/MooseX/Storage/Engine. pm line 36 # MooseX::Storage::Engine::collapse_object('MooseX::Storage::Engine=HASH(0x27cc854)') called at C:/strawberry/perl/site/lib/MooseX/Storage/Basic.pm line 13 # MooseX::Storage::Basic::pack('Siebel::Srvrmgr::ListParser::Output::ListParams=HASH(0x2885034)') called at C:/strawberry/perl/site/lib/MooseX/Storage/IO/StorableFile.pm line 23 # MooseX::Storage::IO::StorableFile::store('Siebel::Srvrmgr::ListParser::Output::ListParams=HASH(0x2885034)', 'foobar') called at C:\Temp\perl\Siebel-Srvrmgr\lib/Siebel/Srvrmgr/Daemon/Ac tion/ListParams.pm line 60 # Siebel::Srvrmgr::Daemon::Action::ListParams::do('Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x27a87b4)', 'ARRAY(0x25f2794)') called at t/Test/Siebel/Srvrmgr/Daemon/Action.pm line 54 # Test::Siebel::Srvrmgr::Daemon::Action::class_methods('Test::Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x2474...') called at C:/strawberry/perl/site/lib/Test/Class.pm line 289 # eval {...} called at C:/strawberry/perl/site/lib/Test/Class.pm line 289 # Test::Class::_run_method('Test::Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x2474...', 'class_methods', 'ARRAY(0x25f15ac)') called at C:/strawberry/perl/site/lib/Test/Class.pm li ne 392 # Test::Class::runtests('Test::Class') called at t\ActionListParams.t line 4) # Failed test 'class_methods died (Cannot handle type constraint (RegexpRef) at C:/strawberry/perl/site/lib/MooseX/Storage/Engine.pm line 354, <DATA> line 1. # MooseX::Storage::Engine::find_type_handler('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::TypeConstraint=HASH(0x20712a4)', 'Regexp=REGEXP(0x27ce1f4)') called at C:/strawberry /perl/site/lib/MooseX/Storage/Engine.pm line 84 # MooseX::Storage::Engine::collapse_attribute_value('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::Attribute=HASH(0x2880844)', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/s ite/lib/MooseX/Storage/Engine.pm line 59 # MooseX::Storage::Engine::collapse_attribute('MooseX::Storage::Engine=HASH(0x27cc854)', 'Moose::Meta::Attribute=HASH(0x2880844)', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/site/li b/MooseX/Storage/Engine.pm line 140 # MooseX::Storage::Engine::map_attributes('MooseX::Storage::Engine=HASH(0x27cc854)', 'collapse_attribute', 'HASH(0x27d1c1c)') called at C:/strawberry/perl/site/lib/MooseX/Storage/Engine. pm line 36 # MooseX::Storage::Engine::collapse_object('MooseX::Storage::Engine=HASH(0x27cc854)') called at C:/strawberry/perl/site/lib/MooseX/Storage/Basic.pm line 13 # MooseX::Storage::Basic::pack('Siebel::Srvrmgr::ListParser::Output::ListParams=HASH(0x2885034)') called at C:/strawberry/perl/site/lib/MooseX/Storage/IO/StorableFile.pm line 23 # MooseX::Storage::IO::StorableFile::store('Siebel::Srvrmgr::ListParser::Output::ListParams=HASH(0x2885034)', 'foobar') called at C:\Temp\perl\Siebel-Srvrmgr\lib/Siebel/Srvrmgr/Daemon/Ac tion/ListParams.pm line 60 # Siebel::Srvrmgr::Daemon::Action::ListParams::do('Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x27a87b4)', 'ARRAY(0x25f2794)') called at t/Test/Siebel/Srvrmgr/Daemon/Action.pm line 54 # Test::Siebel::Srvrmgr::Daemon::Action::class_methods('Test::Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x2474...') called at C:/strawberry/perl/site/lib/Test/Class.pm line 289 # eval {...} called at C:/strawberry/perl/site/lib/Test/Class.pm line 289 # Test::Class::_run_method('Test::Siebel::Srvrmgr::Daemon::Action::ListParams=HASH(0x2474...', 'class_methods', 'ARRAY(0x25f15ac)') called at C:/strawberry/perl/site/lib/Test/Class.pm li ne 392 # Test::Class::runtests('Test::Class') called at t\ActionListParams.t line 4)' # at t\ActionListParams.t line 4. # (in Test::Siebel::Srvrmgr::Daemon::Action::ListParams->class_methods) You can fetch those tests from the project SVN at https://code.google.com/p/siebel-monitoring-tools/source/browse/#svn%2Ftrunk%2FSiebel-Srvrmgr, but let me know if you want to execute some tests. Here is my Perl information: C:\Temp\perl\Siebel-Srvrmgr>perl -V Summary of my perl5 (revision 5 version 16 subversion 3) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='Win32 strawberry-perl 5.16.3.1 #1 Tue Mar 12 13:55:20 2013 i386' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.6.3', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"' libpth=C:\strawberry\c\lib C:\strawberry\c\i686-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomct l32 libc=, so=dll, useshrplib=true, libperl=libperl516.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Mar 12 2013 14:01:07 %ENV: PERL5LIB="C:\Temp\perl\Siebel-Srvrmgr\lib;C:\Temp\perl\Siebel-Srvrmgr\t;C:\Temp\perl\Siebel-Srvrmgr\examples\Siebel-Srvrmgr-Nagios\lib" @INC: C:\Temp\perl\Siebel-Srvrmgr\lib C:\Temp\perl\Siebel-Srvrmgr\t C:\Temp\perl\Siebel-Srvrmgr\examples\Siebel-Srvrmgr-Nagios\lib C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .
Subject: Re: [rt.cpan.org #86415] MooseX::Storage::IO::StorableFile::store does not supports RegexpRef
Date: Tue, 25 Jun 2013 14:26:12 -0700
To: Alceu Rodrigues de Freitas Junior via RT <bug-MooseX-Storage [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Tue, Jun 25, 2013 at 05:17:49PM -0400, Alceu Rodrigues de Freitas Junior via RT wrote: Show quoted text
> > Please, add support to RegexpRef to MooseX::Storage since trying to serialize Moose objects that have attributes with RegexpRef type causes an exception.
This might be difficult to achieve, as regexps stringify differently depending on the version of perl. For example, on 5.16 and above: $ perl -wle'print qr(foo)' (?^:foo) and on 5.14.x: $ perl -wle'print qr(foo)' (?-xism:foo) There might already be prior art which handles these differences, however.
Storable.pm doesn't support serializing/deserializing regexps.
Em Ter Jun 25 17:26:30 2013, ETHER escreveu: Show quoted text
> This might be difficult to achieve, as regexps stringify differently > depending on the version of perl. > > For example, on 5.16 and above: > $ perl -wle'print qr(foo)' > (?^:foo) > > and on 5.14.x: > $ perl -wle'print qr(foo)' > (?-xism:foo) > > There might already be prior art which handles these differences, > however.
Ok, I agree. I think we could do two things to help solving this issue. The first one is add to the Pod of MooseX::Storage what is not supported (regular expression included). Second thing, it may be possible to implement a generic solution that would: a - save the regex text BEFORE using qr on it, in a "hidden" attribute. b - compiling the regex and saving it to the desired attribute c - when calling the store method, internally the class would remove the value of the attribute created in (b) d - when retrieving a serialized object, the class would recreated the compiled regex again into the attribute created in (b) This is a initial brainstorm, I have not tested that yet. I do think that it may be a problem to do that with Moose because the RegexRef would not allow to undef the attribute before serialization (at least by using the writer method). If you have any comments about this approach, that would be great.