From: Graham B. <gb...@po...> - 2000-08-17 16:11:59
|
On Thu, Aug 17, 2000 at 04:56:56PM +0100, John Berthels wrote: > > > would it be better to propogate the Net::LDAP::Message back to the caller? > > > > How would you do that ? Return the message on error and undef otherwise ? > > I guess you could (gack. 'undef' return means success). Or construct a new > ::Message object with a success code? Or stay with what we have here? Well the ::Message in CVS now has is_error, which could be changed to ->success But you loose the usage of the return value as a meaning of success :( > > Also I would rather avoid recursion if possible, I hate recursion. > > Fair enough. Its your module. Not really, not any more. Yes I started it and I may have written most of whats there. But I see most of it's future development coming from others, hopefully I can be a good guide in the process. > I've got as far as putting the opening brace > of a sub on the same line as the name, so I'm gradually getting in sync > with your style :-) :) > I'm not sure I'll easily do the ->save/load as non-recursive though. Oh, I don't know. There is normally a way. But write it as recursive if thats what you feel most comfortable with. Someone with some spare time can always change it later. Often there is not much to change, notice I made little change to your code for the tree delete. > > [snip nice non-recursive tree_delete] > > Nice - except this bit: > > > my $msg = $ldap->search( base => $dn[0], > > scope => 1, > > filter => "(objectclass=*)", > > attr => [ "1.1" ] > > ); > > > > unless( $msg->code() == LDAP_SUCCESS ) { > > $@ = Net::LDAP::Util::ldap_error_text( $msg->code() ); > > return undef; > > } > > > > unshift @dn, $msg->entries; > > needs > > > unshift @dn, map { $_->dn() } $msg->entries; No. base to ->search can be an Entry object. In which case ->search will call ->dn for you. > Or perhaps you mean: > > unshift @dn, $ldap->list( $dn ); > > instead :-) Maybe, but then I loose the Message, so I don't know if there are no children of if there was an error. I guess I could check $@. Graham. |