Send Netdot-devel mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."
Today's Topics:
1. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.5-rc1-9-g22c77d1 ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 5 Feb 2014 12:07:00 -0800
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.5-rc1-9-g22c77d1
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via 22c77d19d4da4bc0628d3ab7b1d2771d2120c931 (commit)
from 85243da281a7b41f3baf4ae4e0fd7a2531a09320 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 22c77d19d4da4bc0628d3ab7b1d2771d2120c931
Author: Carlos Vicente <[email protected]>
Date: Wed Feb 5 15:06:53 2014 -0500
Correction to previous commit
diff --git a/lib/Netdot/Model/Picture.pm b/lib/Netdot/Model/Picture.pm
index 1979583..b16bd2f 100644
--- a/lib/Netdot/Model/Picture.pm
+++ b/lib/Netdot/Model/Picture.pm
@@ -57,52 +57,14 @@ sub insert {
}
#################################################
-# Add some triggers
+# Handle PostgreSQL's bytea types correctly.
#
-# Postgresql's fields of type 'bytea' must be encoded prior to storing
-#
-__PACKAGE__->add_trigger( deflate_for_create => \&_encode_bindata );
-__PACKAGE__->add_trigger( deflate_for_update => \&_encode_bindata );
-__PACKAGE__->add_trigger( select => \&_decode_bindata );
-
-#################################################
-#
-# Called before insert/update
-#
-sub _encode_bindata{
- my $self = shift;
- return 1 unless ( $self->config->get('DB_TYPE') eq 'Pg' );
- my $data = ($self->_attrs('bindata'))[0];
- $data = APR::Base64::encode($data);
- $self->_attribute_store( bindata => $data );
- return 1;
-}
-#################################################
-#
-# Called before select
-#
-sub _decode_bindata{
- my $self = shift;
- return 1 unless ( $self->config->get('DB_TYPE') eq 'Pg' );
- my $id = $self->id;
- my $dbh = $self->db_Main;
- my $table = lc($self->table);
- my $encoded = ($dbh->selectrow_array("SELECT bindata FROM $table WHERE id
= $id"))[0];
- unless ( $encoded ){
- $logger->error("Picture::_decode_bindata: No bindata available for
$table id $id");
- return 1;
- }
- my $decoded = APR::Base64::decode($encoded);
- unless ( $decoded ){
- $logger->error("Picture::_decode_bindata: Problem decoding bindata for
$table id $id");
- return 1;
- }
- $self->_attribute_store( bindata => $decoded );
- return 1;
+if (__PACKAGE__->config->get('DB_TYPE') eq 'Pg') {
+ require DBD::Pg;
+ __PACKAGE__->data_type(bindata => { pg_type => &DBD::Pg::PG_BYTEA });
}
-
=head1 AUTHOR
Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
diff --git a/t/SitePicture.t b/t/SitePicture.t
new file mode 100644
index 0000000..1d13515
--- /dev/null
+++ b/t/SitePicture.t
@@ -0,0 +1,82 @@
+use strict;
+use warnings;
+use Test::More;
+use lib "lib";
+use Data::Dumper;
+use FindBin;
+
+BEGIN { use_ok('Netdot::Model::Site'); }
+BEGIN { use_ok('Netdot::Model::SitePicture'); }
+
+my $site = Site->insert({ name => "t/SitePicture.t" });
+ok($site, "site insert");
+
+my $picture_file = "$FindBin::Bin/../htdocs/img/title.png";
+ok(-f($picture_file), "picture file exists");
+
+my $picture_data;
+{
+ local $/;
+ if (open my $fh, "<", $picture_file) {
+ $picture_data = <$fh>;
+ }
+}
+is(length($picture_data), 8826, "the picture is right");
+
+my $pic = SitePicture->insert({
+ site => $site->id,
+ filename => $picture_file,
+ bindata => $picture_data,
+});
+ok($pic, "picture insert");
+
+is($pic->bindata, $picture_data, "picture object holds correct data");
+my $pic_id = $pic->id;
+undef $pic;
+$pic = SitePicture->retrieve($pic_id);
+ok($pic, "picture retrieve");
+
+is($pic->bindata, $picture_data, "retrieved picture object holds correct
data");
+
+$site->delete;
+isa_ok($site, 'Class::DBI::Object::Has::Been::Deleted', 'cleanup ok');
+
+done_testing;
+exit;
+
+# Ipblock
+my $subnet = Ipblock->insert({address => '1.1.1.0',
+ prefix => 24,
+ status => 'Subnet'});
+my $subnet_id = $subnet->id;
+ok(defined $subnet, 'subnet insert');
+
+$subnet->set('description', 'test1');
+ok($subnet->update, "update without params returns success");
+undef $subnet;
+$subnet = Ipblock->retrieve($subnet_id);
+is($subnet->description, 'test1', 'update without params');
+
+ok($subnet->update({description => 'test2'}), "update with params returns
success");
+undef $subnet;
+$subnet = Ipblock->retrieve($subnet_id);
+is($subnet->description, 'test2', 'update with params');
+
+eval {
+ my $vlan = Vlan->insert({name => 'test vlan',
+ vid => 1});
+ ok(defined $vlan, "vlan insert");
+
+ $subnet->update({vlan => $vlan});
+ is($subnet->vlan, $vlan, 'set vlan to subnet');
+
+ $vlan->delete;
+ undef $subnet;
+ $subnet = Ipblock->retrieve($subnet_id);
+ ok(!$subnet->vlan, 'nullify');
+};
+fail($@) if $@;
+
+$subnet->delete;
+
+done_testing;
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Picture.pm | 46 +++----------------------
t/SitePicture.t | 82 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 42 deletions(-)
create mode 100644 t/SitePicture.t
hooks/post-receive
--
Netdot
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 83, Issue 5
*******************************************