| 7 |
############################################ |
############################################ |
| 8 |
# |
# |
| 9 |
# $Log$ |
# $Log$ |
| 10 |
|
# Revision 1.11 2002/12/11 06:53:19 joko |
| 11 |
|
# + updated pod |
| 12 |
|
# |
| 13 |
|
# Revision 1.10 2002/12/07 03:37:23 joko |
| 14 |
|
# + updated pod |
| 15 |
|
# |
| 16 |
|
# Revision 1.9 2002/12/01 22:15:45 joko |
| 17 |
|
# - sub createDb: moved to handler |
| 18 |
|
# |
| 19 |
# Revision 1.8 2002/11/29 04:48:23 joko |
# Revision 1.8 2002/11/29 04:48:23 joko |
| 20 |
# + updated pod |
# + updated pod |
| 21 |
# |
# |
| 56 |
|
|
| 57 |
=head1 NAME |
=head1 NAME |
| 58 |
|
|
| 59 |
Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way |
Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way |
| 60 |
|
|
| 61 |
|
|
| 62 |
=head1 AIMS |
=head1 AIMS |
| 170 |
|
|
| 171 |
=head2 NOTE |
=head2 NOTE |
| 172 |
|
|
| 173 |
This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks. |
This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks. |
| 174 |
Please look at their documentation and/or this code for additional information. |
Please look at their documentation and/or this code for additional information. |
| 175 |
|
|
| 176 |
|
|
| 177 |
=head1 REQUIREMENTS |
=head1 REQUIREMENTS |
| 371 |
if ( my $dbh = DBI->connect($dsn, '', '', { |
if ( my $dbh = DBI->connect($dsn, '', '', { |
| 372 |
PrintError => 0, |
PrintError => 0, |
| 373 |
} ) ) { |
} ) ) { |
| 374 |
|
|
| 375 |
|
# TODO: REVIEW |
| 376 |
$dbh->disconnect(); |
$dbh->disconnect(); |
| 377 |
|
|
| 378 |
return 1; |
return 1; |
| 379 |
} else { |
} else { |
| 380 |
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
| 388 |
return $status; |
return $status; |
| 389 |
} |
} |
| 390 |
|
|
|
sub createDb { |
|
|
my $self = shift; |
|
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
|
|
|
|
$logger->debug( __PACKAGE__ . "->createDb( dsn $dsn )" ); |
|
|
|
|
|
$dsn =~ s/database=(.+?);//; |
|
|
my $database_name = $1; |
|
|
|
|
|
my $ok; |
|
|
|
|
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
|
|
PrintError => 0, |
|
|
} ) ) { |
|
|
if ($database_name) { |
|
|
if ($dbh->do("CREATE DATABASE $database_name;")) { |
|
|
$ok = 1; |
|
|
} |
|
|
} |
|
|
$dbh->disconnect(); |
|
|
} |
|
|
|
|
|
return $ok; |
|
|
|
|
|
} |
|
| 391 |
|
|
| 392 |
sub dropDb { |
sub dropDb { |
| 393 |
my $self = shift; |
my $self = shift; |
| 408 |
$ok = 1; |
$ok = 1; |
| 409 |
} |
} |
| 410 |
} |
} |
| 411 |
|
|
| 412 |
$dbh->disconnect(); |
$dbh->disconnect(); |
| 413 |
|
|
| 414 |
} |
} |
| 415 |
|
|
| 416 |
return $ok; |
return $ok; |
| 427 |
|
|
| 428 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
| 429 |
|
|
| 430 |
Data::Storage is a module for accessing various "data structures" stored inside |
=head2 Data::Storage |
|
various "data containers". It sits on top of DBI and/or Tangram. |
|
| 431 |
|
|
| 432 |
|
Data::Storage is a module for accessing various "data structures / kinds of structured data" stored inside |
| 433 |
|
various "data containers". |
| 434 |
|
We tried to use the AdapterPattern (http://c2.com/cgi/wiki?AdapterPattern) to implement a wrapper-layer |
| 435 |
|
around core CPAN modules (Tangram, DBI). |
| 436 |
|
|
| 437 |
|
=head2 Why? |
| 438 |
|
|
| 439 |
|
You will get a better code-structure (not bad for later maintenance) in growing Perl code projects, |
| 440 |
|
especially when using multiple database connections at the same time. |
| 441 |
|
You will be able to switch between different _kinds_ of implementations used for storing data. |
| 442 |
|
Your code will use the very same API to access these storage layers. |
| 443 |
|
... implementation has to be changed for now |
| 444 |
|
Maybe you will be able to switch "on-the-fly" without changing any bits in code in the future.... |
| 445 |
|
... but that's not the focus |
| 446 |
|
|
| 447 |
=head1 AUTHORS / COPYRIGHT |
=head2 What else? |
| 448 |
|
|
| 449 |
The Data::Storage module is Copyright (c) 2002 Andreas Motl. |
Having this, we were able to do implement a generic data synchronization module more easy, |
| 450 |
All rights reserved. |
please look at Data::Transfer. |
| 451 |
|
|
| 452 |
You may distribute it under the terms of either the GNU General Public |
|
| 453 |
License or the Artistic License, as specified in the Perl README file. |
=head1 AUTHORS / COPYRIGHT |
| 454 |
|
|
| 455 |
|
The Data::Storage module is Copyright (c) 2002 Andreas Motl. |
| 456 |
|
All rights reserved. |
| 457 |
|
You may distribute it under the terms of either the GNU General Public |
| 458 |
|
License or the Artistic License, as specified in the Perl README file. |
| 459 |
|
|
| 460 |
|
|
| 461 |
=head1 ACKNOWLEDGEMENTS |
=head1 ACKNOWLEDGEMENTS |
| 462 |
|
|
| 463 |
Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object, |
Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object, |
| 464 |
Sam Vilain for Class::Tangram, Jochen Wiedmann and Jeff Zucker for DBD::CSV and related, |
Sam Vilain for Class::Tangram, Jochen Wiedmann and Jeff Zucker for DBD::CSV & Co., |
| 465 |
Adam Spiers for MySQL::Diff and all contributors. |
Adam Spiers for MySQL::Diff and all contributors. |
| 466 |
|
|
| 467 |
|
|
| 468 |
=head1 SUPPORT / WARRANTY |
=head1 SUPPORT / WARRANTY |
| 469 |
|
|
| 470 |
Data::Storage is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. |
Data::Storage is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. |
| 471 |
|
|
| 472 |
|
|
| 473 |
=head1 TODO |
=head1 TODO |
| 538 |
- .pst - files (Outlook Post Storage?) |
- .pst - files (Outlook Post Storage?) |
| 539 |
- XML (e.g. via XML::Simple?) |
- XML (e.g. via XML::Simple?) |
| 540 |
- Move to t3, look at InCASE |
- Move to t3, look at InCASE |
| 541 |
|
- some kind of security layer for methods/objects |
| 542 |
|
- acls (stored via tangram/ldap?) for functions, methods and objects (entity- & data!?) |
| 543 |
|
- where are the hooks needed then? |
| 544 |
|
- is Data::Storage & Co. okay, or do we have to touch the innards of DBI and/or Tangram? |
| 545 |
|
- an attempt to start could be: |
| 546 |
|
- 'sub getACLByObjectId($id, $context)' |
| 547 |
|
- 'sub getACLByMethodname($id, $context)' |
| 548 |
|
- 'sub getACLByName($id, $context)' |
| 549 |
|
( would require a kinda registry to look up these very names pointing to arbitrary locations (code, data, ...) ) |
| 550 |
|
|
| 551 |
|
|
| 552 |
|
|
| 553 |
=head3 LINKS / REFERENCES |
=head3 LINKS / REFERENCES |