thanks again for this, svilen.
i took what you posted, plus the followups from jsiracusa, and got
something going. your code was very helpful.
i made some slight adjustments, notably calling $class->freeze/thaw
in the methodmaker, and implementing those as class methods there.
that allowed me to do something like:
package My::MethodMaker::Serialized::JSON;
use base 'My::MethodMaker::Serialized';
use JSON;
sub freeze { JSON->new->objToJson($_[1]) }
sub thaw { JSON->new(skipinvalid => 1)->jsonToObj($_[1]) }
1;
package My::MethodMaker::Serialized::YAML;
use base 'My::MethodMaker::Serialized';
use YAML::Syck();
sub freeze { YAML::Syck::Dump($_[1]) }
sub thaw { YAML::Syck::Load($_[1]) }
1;
package My::MethodMaker::Serialized::Storable;
use base 'My::MethodMaker::Serialized';
use Storable();
sub freeze { Storable::freeze($_[1]) }
sub thaw { Storable::thaw($_[1]) }
1;
add some little My::Column::Serialized::* wrappers to do the
method_maker_class/type bits, plus this in My::MetaData
__PACKAGE__->column_type_class(serialized_storable =>
'Plex::RDBO::_serialized_storable_column');
__PACKAGE__->column_type_class(serialized_yaml =>
'Plex::RDBO::_serialized_yaml_column');
__PACKAGE__->column_type_class(serialized_json =>
'Plex::RDBO::_serialized_json_column');
and now i can
__PACKAGE__->meta->setup(
table => 'user',
columns => [
...
payload => { type => 'serialized_yaml' },
], ...
and things are working great!
regards,
michael.
On Jun 19, 2007, at 10:43 PM, Svilen Ivanov wrote:
> Michael,
>
> Check this thread:
> http://www.mail-archive.com/[email protected]/
> msg00260.html
>
> I hope that helps
>
> 2007/6/20, Michael Reece <[EMAIL PROTECTED]>:
>>
>> i am looking to freeze/thaw (or yaml, doesn't really matter..)
>> unblessed data structures into a mysql column.
>>
>> has anyone already written a Column class that handles this
>> transparently?
>>
>> ---
>> michael reece :: software engineer :: [EMAIL PROTECTED]
>>
>>
>>
>> ---------------------------------------------------------------------
>> ----
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Rose-db-object mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/rose-db-object
>>
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Rose-db-object mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rose-db-object
---
michael reece :: software engineer :: [EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object