[prev] [thread] [next] [lurker] [Date index for 2002/09/02]
Update of /cvsroot/siesta/siesta/lib/Siesta In directory usw-pr-cvs1:/tmp/cvs-serv31085/lib/Siesta Modified Files: Config.pm List.pm User.pm Log Message: Huge batch of changes to get config working. Index: Config.pm =================================================================== RCS file: /cvsroot/siesta/siesta/lib/Siesta/Config.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Config.pm 2 Sep 2002 11:44:45 -0000 1.6 +++ Config.pm 2 Sep 2002 15:16:07 -0000 1.7 @@ -13,13 +13,29 @@ sub new {} # nop +=pod + +=head1 NAME + +Siesta::Config - base class for config management + +=head1 USAGE + +Shouldn't be used directly. Subclass in the Siesta::Config:: namespace. + +=head1 SEE ALSO + +L<Siesta::Config::User>, L<Siesta::Config::List> + +=cut + # get a value from the the config data base sub get { - my ($self, $id, $namespace, $key) = @_; + my ($self, $namespace, $key) = @_; my $sth = $self->sql_get; - my @vals = ($id, $namespace, $key); + my @vals = ($self->{id}, $namespace, $key); $sth->execute(@vals); my $values = $sth->fetch; @@ -31,21 +47,21 @@ # set a value in the the config data base sub set { - my ($self, $id, $namespace, $key, $value) = @_; + my ($self, $namespace, $key, $value) = @_; # are we inserting or updating? my $sth; - my $current = $self->get($id, $namespace, $key); + my $current = $self->get($namespace, $key); unless ($current) { $sth = $self->sql_insert(); return undef unless defined $sth; - my @values = ($id, $namespace, $key, $value); + my @values = ($self->{id}, $namespace, $key, $value); return $sth->execute(@values); } else { $sth = $self->sql_update(); return undef unless defined $sth; - my @values = ($value, $id, $namespace, $key); + my @values = ($value, $self->{id}, $namespace, $key); return $sth->execute(@values); } Index: List.pm =================================================================== RCS file: /cvsroot/siesta/siesta/lib/Siesta/List.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- List.pm 28 Aug 2002 10:06:28 -0000 1.21 +++ List.pm 2 Sep 2002 15:16:08 -0000 1.22 @@ -1,29 +1,42 @@ # $Id$ + +package Siesta::List; + +use strict; +use Class::MethodMaker get_set => [ qw( id owner post_address return_path created ) ]; + +use Siesta; +use Siesta::User; +use Siesta::Config::List; + =pod =head1 NAME -Siesta::List +Siesta::List - manipulate a list -=head1 DESCRIPTION - -The List object for the Sierra system. =head1 METHODS -=cut +=head2 (get|set)_id -package Siesta::List; +get and set the id (must be unique) -use strict; -use Class::MethodMaker get_set => [ qw( id owner post_address return_path created ) ]; +=head2 (get|set)_owner -use Siesta; -use Siesta::User; +get and set the owner (usually an email address) -=head2 new(id) +=head2 (get|set)_post_address -This is actually performing more like load at the minute. +the email address that people post to send to this list. + +=head2 (get|set)_return_path + +the email address that bounces should come back to + +=head2 (get|set)_created + +the date it was created =cut @@ -34,6 +47,10 @@ my %list = Siesta->storage->load_list( $id ); return unless %list; + my $list_config = new Siesta::Config::List($id); + + $list{'config'} = $list_config; + return bless \%list, $class; } @@ -112,5 +129,36 @@ # this would make it consistent with members() Siesta->storage->list_plugins( $self->id ); } + +=head2 (get|set)_config() + +get and set config values for this User. + +=cut + +sub get_config +{ + my ($self, $namespace, $key) = @_; + + return $self->{config}->get($namespace, $key); + +} + +sub set_config +{ + my ($self, $namespace, $key, $value) = @_; + + return $self->{config}->set($namespace, $key, $value); + +} + +=pod + +=head1 SEE ALSO + +L<Siesta::Config::List> + +=cut + 1; Index: User.pm =================================================================== RCS file: /cvsroot/siesta/siesta/lib/Siesta/User.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- User.pm 28 Aug 2002 10:06:29 -0000 1.6 +++ User.pm 2 Sep 2002 15:16:08 -0000 1.7 @@ -1,5 +1,6 @@ package Siesta::User; use strict; +use Siesta::Config::User; # fuck the users, fuck them up their stupid asses use Class::MethodMaker @@ -7,14 +8,73 @@ use Siesta; + + +=pod + +=head1 NAME + +Siesta::User - manipulate a user + + +=head1 METHODS + +=head2 (get|set)_id + +get and set their id (usually their email address) + +=head2 (get|set)_forename + +get and set their forename + + +=head2 (get|set)_surname + +get and set their surname + +=head2 (get|set)_config + +get and set config values for this User. + +=back + +=head1 SEE ALSO + +L<Siesta::Config::User> + +=cut + sub new { my $class = shift; my $id = shift; my %user = Siesta->storage->load_user( $id ); return unless %user; + + my $user_config = new Siesta::Config::User($id); + $user{config} = $user_config; + return bless \%user, $class; } + + +sub get_config +{ + my ($self, $namespace, $key) = @_; + + return $self->{config}->get($namespace, $key); + +} + +sub set_config +{ + my ($self, $namespace, $key, $value) = @_; + + return $self->{config}->set($namespace, $key, $value); + +} + + 1;
Generated at 13:57 on 01 Jul 2004 by mariachi 0.52