| 1 | ############################################################################# | ||
| 2 | # | ||
| 3 | # Apache::Session::Serialize::Sybase | ||
| 4 | # Serializes session objects using Storable and packing into Sybase format | ||
| 5 | # Copyright(c) 2000 Jeffrey William Baker (jwbaker@acm.org) | ||
| 6 | # Modified from Apache::Session::Serialize::Storable by Chris Winters (chris@cwinters.com) | ||
| 7 | # Distribute under the Perl License | ||
| 8 | # | ||
| 9 | ############################################################################ | ||
| 10 | |||
| 11 | package Apache::Session::Serialize::Sybase; | ||
| 12 | |||
| 13 | use strict; | ||
| 14 | use vars qw( $VERSION ); | ||
| 15 | |||
| 16 | use Apache::Session::Serialize::Storable; | ||
| 17 | |||
| 18 | $VERSION = '1.00'; | ||
| 19 | |||
| 20 | # Modify the storable-serialized data to work with sybase | ||
| 21 | sub serialize { | ||
| 22 | my $session = shift; | ||
| 23 | Apache::Session::Serialize::Storable::serialize( $session ); # sets $session->{serialized} | ||
| 24 | $session->{serialized} = unpack('H*', $session->{serialized} ); | ||
| 25 | } | ||
| 26 | |||
| 27 | # Modify the data from sybase to work with storable so it can thaw properly | ||
| 28 | sub unserialize { | ||
| 29 | my $session = shift; | ||
| 30 | $session->{serialized} = pack('H*', $session->{serialized} ); | ||
| 31 | Apache::Session::Serialize::Storable::unserialize( $session ); # sets $session->{data} | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; | ||
| 35 | |||
| 36 | =pod | ||
| 37 | |||
| 38 | =head1 NAME | ||
| 39 | |||
| 40 | Apache::Session::Serialize::Sybase - Use Storable to zip up persistent data and unpack/pack to put into Sybase-compatible image field | ||
| 41 | |||
| 42 | =head1 SYNOPSIS | ||
| 43 | |||
| 44 | use Apache::Session::Serialize::Sybase; | ||
| 45 | |||
| 46 | $zipped = Apache::Session::Serialize::Sybase::serialize($ref); | ||
| 47 | $ref = Apache::Session::Serialize::Sybase::unserialize($zipped); | ||
| 48 | |||
| 49 | =head1 DESCRIPTION | ||
| 50 | |||
| 51 | This module fulfills the serialization interface of Apache::Session by | ||
| 52 | taking the data from Apache::Session::Serialize::Storable and modifying | ||
| 53 | it to work with Sybase IMAGE fields. Note that you do B<not> need to | ||
| 54 | quote these values before inserting into the database, and that if you | ||
| 55 | are using DBI::Sybase, you cannot use the data in a placeholder. If you | ||
| 56 | use Apache::Session::Sybase as your session class, this will all | ||
| 57 | get taken care of. | ||
| 58 | |||
| 59 | =head1 AUTHOR | ||
| 60 | |||
| 61 | Apache::Session::Serialize::Storable was written by | ||
| 62 | Jeffrey William Baker <jwbaker@acm.org>; the Sybase-specific data | ||
| 63 | manipulation was written by Mark Landry <mdlandry@lincoln.midcoast.com> | ||
| 64 | for use in an earlier version of Apache::Session::DBI::Sybase and | ||
| 65 | placed here by Chris Winters <chris@cwinters.com>. | ||
| 66 | |||
| 67 | =head1 SEE ALSO | ||
| 68 | |||
| 69 | L<Apache::Session::Serialize::Storable>, L<Apache::Session::Sybase> |