Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm	(revision 1046)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm	(revision 1047)
@@ -105,4 +105,155 @@
         !m/^sync:/
     } $self->Sections
+}
+
+=head2 default_base_name
+
+Return the default base name according config file
+
+=cut
+
+sub default_base_name {
+    my ($self) = @_;
+    $self->val('_default_', 'base', ($self->list_bases)[0]);
+}
+
+=head2 base($basename)
+
+Return a L<LATMOS::Accounts::Base> object over base named $basename
+defined in the config file.
+
+The base is loaded by this function.
+
+=cut
+
+sub base {
+    my ($self, $section) = @_;
+    # this method perform a cache
+    $self->_load_base($section || $self->default_base_name);
+}
+
+# do the bad work
+sub _load_base {
+    my ($self, $section) = @_;
+    my $type = $self->val($section, 'type') or return;
+    my %params = (
+        map { $_ => ($self->val($section, $_)) } $self->Parameters($section),
+        defattr => { map { $_ => ($self->val('_defattr_', $_)) } $self->Parameters('_defattr_') },
+    );
+    my $base = LATMOS::Accounts::Bases->new(
+        $type,
+        %params,
+        label => $section,
+        acls => $self->{_acls},
+        allowed_values => $self->{_allowed_values},
+        configdir => $self->_configdir,
+        _la => $self,
+    ) or do {
+        la_log(LA_WARN, "Cannot instanciate base $section ($type)");
+        return;
+    };
+    $base->load or return;
+    $base;
+}
+
+=head2 list_synchro
+
+List synchronisation setup in L<latmos-accounts.ini>
+
+=cut
+
+sub list_synchro {
+    my ($self) = @_;
+    grep { $_ } map { /^sync:(.*)$/; $1 } $self->Sections
+}
+
+=head2 default_synchro_name
+
+Return de default synchronisation name
+
+=cut
+
+sub default_synchro_name {
+    my ($self) = @_;
+    $self->val('_default_', 'sync');
+}
+
+=head2 default_synchro
+
+Return a reference to default synchronisation object
+
+=cut
+
+sub default_synchro {
+    my ($self, %options) = @_;
+    my $syncname = $self->default_synchro_name or do {
+        la_log(LA_ERR, 'Cannot find default synchro in config');
+        return;
+    };
+    $self->create_synchro($syncname, %options);
+}
+
+=head2 create_synchro($name, %options)
+
+Return a reference to synchronisation object for C<$name> synchronisation.
+
+=cut
+
+sub create_synchro {
+    my ($self, $name, %options) = @_;
+
+    # taking options from config
+    if ($name) {
+        foreach my $param ($self->Parameters("sync:$name")) {
+            if (!defined($options{$param})) {
+                my @args = $self->val("sync:$name", $param);
+                $options{$param} = ($args[1] || $param eq 'to')
+                    ? [ @args ]
+                    : $args[0];
+            }
+        }
+    }
+
+    my $labfrom = $options{from} ? $self->base($options{from}) : $self->default_base;
+
+    my @labto =
+        grep { $_ }
+        map { $self->base($_) }
+        @{ $options{to} || []}
+        or do {
+        la_log(LA_ERR, "No destination base load in this synchro");
+        return;
+    };
+
+    my $sync = LATMOS::Accounts::Synchro->new(
+        $labfrom, [ @labto ],
+        state_dir => ($self->val('_default_', 'state_dir') || undef),
+        %options,
+        name => $name,
+    );
+}
+
+=head2 sync_access($name, %options)
+
+Return a L<LATMOS::Accounts::SynchAccess> object over C<$name> synchronisation.
+
+=cut
+
+sub sync_access {
+    my ($self, $name, %options) = @_;
+
+    my @obases;
+    if ($name) {
+        @obases =
+        (map { $self->base($_) } ($self->sync_from_name($name), $self->val("sync:$name", 'to')));
+    } elsif(@{ $options{bases} || []}) {
+        @obases = map { $self->base($_) } @{ $options{bases} || []};
+    } elsif (my $sname = $self->default_synchro_name) {
+        @obases = (map { $self->base($_) }
+            ($self->sync_from_name($sname), $self->val("sync:$sname", 'to'))
+        );
+    }
+
+    LATMOS::Accounts::SynchAccess->new([ @obases ]);
 }
 
@@ -137,155 +288,4 @@
 }
 
-=head2 default_base_name
-
-Return the default base name according config file
-
-=cut
-
-sub default_base_name {
-    my ($self) = @_;
-    $self->val('_default_', 'base', ($self->list_bases)[0]);
-}
-
-=head2 base($basename)
-
-Return a L<LATMOS::Accounts::Base> object over base named $basename
-defined in the config file.
-
-The base is loaded by this function.
-
-=cut
-
-sub base {
-    my ($self, $section) = @_;
-    # this method perform a cache
-    $self->_load_base($section || $self->default_base_name);
-}
-
-# do the bad work
-sub _load_base {
-    my ($self, $section) = @_;
-    my $type = $self->val($section, 'type') or return;
-    my %params = (
-        map { $_ => ($self->val($section, $_)) } $self->Parameters($section),
-        defattr => { map { $_ => ($self->val('_defattr_', $_)) } $self->Parameters('_defattr_') },
-    );
-    my $base = LATMOS::Accounts::Bases->new(
-        $type,
-        %params,
-        label => $section,
-        acls => $self->{_acls},
-        allowed_values => $self->{_allowed_values},
-        configdir => $self->_configdir,
-        _la => $self,
-    ) or do {
-        la_log(LA_WARN, "Cannot instanciate base $section ($type)");
-        return;
-    };
-    $base->load or return;
-    $base;
-}
-
-=head2 list_synchro
-
-List synchronisation setup in L<latmos-accounts.ini>
-
-=cut
-
-sub list_synchro {
-    my ($self) = @_;
-    grep { $_ } map { /^sync:(.*)$/; $1 } $self->Sections
-}
-
-=head2 default_synchro_name
-
-Return de default synchronisation name
-
-=cut
-
-sub default_synchro_name {
-    my ($self) = @_;
-    $self->val('_default_', 'sync');
-}
-
-=head2 default_synchro
-
-Return a reference to default synchronisation object
-
-=cut
-
-sub default_synchro {
-    my ($self, %options) = @_;
-    my $syncname = $self->default_synchro_name or do {
-        la_log(LA_ERR, 'Cannot find default synchro in config');
-        return;
-    };
-    $self->create_synchro($syncname, %options);
-}
-
-=head2 create_synchro($name, %options)
-
-Return a reference to synchronisation object for C<$name> synchronisation.
-
-=cut
-
-sub create_synchro {
-    my ($self, $name, %options) = @_;
-
-    # taking options from config
-    if ($name) {
-        foreach my $param ($self->Parameters("sync:$name")) {
-            if (!defined($options{$param})) {
-                my @args = $self->val("sync:$name", $param);
-                $options{$param} = ($args[1] || $param eq 'to')
-                    ? [ @args ]
-                    : $args[0];
-            }
-        }
-    }
-
-    my $labfrom = $options{from} ? $self->base($options{from}) : $self->default_base;
-
-    my @labto =
-        grep { $_ }
-        map { $self->base($_) }
-        @{ $options{to} || []}
-        or do {
-        la_log(LA_ERR, "No destination base load in this synchro");
-        return;
-    };
-
-    my $sync = LATMOS::Accounts::Synchro->new(
-        $labfrom, [ @labto ],
-        state_dir => ($self->val('_default_', 'state_dir') || undef),
-        %options,
-        name => $name,
-    );
-}
-
-=head2 sync_access($name, %options)
-
-Return a L<LATMOS::Accounts::SynchAccess> object over C<$name> synchronisation.
-
-=cut
-
-sub sync_access {
-    my ($self, $name, %options) = @_;
-
-    my @obases;
-    if ($name) {
-        @obases =
-        (map { $self->base($_) } ($self->sync_from_name($name), $self->val("sync:$name", 'to')));
-    } elsif(@{ $options{bases} || []}) {
-        @obases = map { $self->base($_) } @{ $options{bases} || []};
-    } elsif (my $sname = $self->default_synchro_name) {
-        @obases = (map { $self->base($_) }
-            ($self->sync_from_name($sname), $self->val("sync:$sname", 'to'))
-        );
-    }
-
-    LATMOS::Accounts::SynchAccess->new([ @obases ]);
-}
-
 1;
 
