| 253 |
{ |
{ |
| 254 |
my $self = shift; |
my $self = shift; |
| 255 |
|
|
| 256 |
eval ("use Data::UUID;"); |
my $guid; |
| 257 |
my $ug = Data::UUID->new(); |
|
| 258 |
my $guid = $ug->create_str(); |
# try to use Data::UUID first ... |
| 259 |
|
eval("use Data::UUID;"); |
| 260 |
|
if (!$@) { |
| 261 |
|
my $ug = Data::UUID->new(); |
| 262 |
|
$guid = $ug->create_str(); |
| 263 |
|
|
| 264 |
|
# ... if this fails, try to fallback to Data::UUID::PurePerl instead ... |
| 265 |
|
} else { |
| 266 |
|
eval("use Data::UUID::PurePerl;"); |
| 267 |
|
if (!$@) { |
| 268 |
|
$guid = Data::UUID::PurePerl::generate_id(); |
| 269 |
|
} else { |
| 270 |
|
croak "couldn't create globally unique identifier"; |
| 271 |
|
} |
| 272 |
|
} |
| 273 |
|
|
| 274 |
return $guid; |
return $guid; |
| 275 |
} |
} |
| 482 |
return $self->id($obj) |
return $self->id($obj) |
| 483 |
if $self->id($obj); |
if $self->id($obj); |
| 484 |
|
|
| 485 |
# insert global unique identifier in object to persist across re-deploys |
# insert global unique identifier in object to persist across re-deploys |
| 486 |
$obj->{guid} = $self->make_guid(); |
$obj->{guid} = $self->make_guid(); |
|
|
|
|
# debug |
|
|
use Data::Dumper; |
|
|
print Dumper($obj); |
|
| 487 |
|
|
| 488 |
$saving->insert($obj); |
$saving->insert($obj); |
| 489 |
|
|