Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm	(revision 1286)
@@ -110,4 +110,15 @@
     my $prefix = 'Base(' . $self->type . '/' . $self->label . ')';
     LATMOS::Accounts::Log::la_log($level, "$prefix $msg", @args);
+}
+
+=head2 logChanges($otype, $name, $ref, $changetype, $message, @args)
+
+Functions to report back
+
+=cut 
+
+sub ReportChange {
+    my ($self, $otype, $name, $ref, $changetype, $message, @args) = @_;
+
 }
 
@@ -437,5 +448,7 @@
     }
     #keys %data or return 0; # TODO: return an error ?
-    $self->create_object($otype, $id, %data);
+    my $obj = $self->create_object($otype, $id, %data);
+    $obj->ReportChange('Create', 'Object created');
+    $obj
 }
 
@@ -614,5 +627,10 @@
         return;
     };
-    $self->_delete_object($otype, $id);
+    my $ref = $obj->Iid;
+    if (my $res = $self->_delete_object($otype, $id)) {
+        $self->ReportChange($otype, $id, $ref, 'Delete', 'Object deleted');
+        return $res;
+    }
+    return;
 }
 
@@ -650,5 +668,18 @@
     };
 
-    $self->_rename_object($otype, $id, $newid);
+    my $oldref = $obj->Iid;
+
+    if (my $res = $self->_rename_object($otype, $id, $newid)) {
+        my $newobj = $self->get_object($otype, $newid) or do {
+            $self->log(LA_WARN, 'Cannot get object %s/%s: rename failed ?',
+                $otype, $id);
+            return;
+        };
+
+        $self->ReportChange($otype, $id, $oldref, 'Rename', 'Object rename to %s', $newid);
+        $newobj->ReportChange('Rename', 'Object renamed from %s', $id);
+        return $res;
+    }
+    return;
 }
 
Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm	(revision 1286)
@@ -128,4 +128,16 @@
     my ($self) = @_;
     $self->{_id}
+}
+
+
+=head2 Iid
+
+Return internal id if different from Id
+
+=cut
+
+sub Iid {
+    my ($self) = @_;
+    $self->id
 }
 
@@ -368,8 +380,31 @@
             return 0;
         };
-        $res += ($attribute->set($cdata{$cfield}) || 0);
-
-    }
-    $res
+    }
+
+    my %updated = ();
+    foreach my $cfield (keys %cdata) {
+        my $attribute = $self->attribute($cfield) or do {
+            $self->base->log(LA_ERR,
+                "Cannot set unsupported attribute %s to %s (%s)",
+                $cfield, $self->id, $self->type
+            );
+            return;
+        };
+        if ($attribute->set($cdata{$cfield})) {
+            $updated{$cfield} = $attribute->{notify};
+        }
+    }
+    
+    if (keys %updated) {
+        $self->ReportChange('Update', 'Attributes %s where updated', join(', ', sort keys %updated));
+        foreach (sort keys %updated) {
+            $self->ReportChange('Attributes', '%s set to %s', $_, 
+                (ref $cdata{$_}
+                    ? join(', ', @{ $cdata{$_} })
+                    : $cdata{$_}) || '(none)')
+                if ($updated{$_});
+        }
+    }
+    return scalar(keys %updated);
 }
 
@@ -390,5 +425,10 @@
     my ($self, $clear_pass) = @_;
     if ($self->base->check_acl($self, 'userPassword', 'w')) {
-        return $self->_set_password($clear_pass);
+        if ($self->_set_password($clear_pass)) {
+             $self->ReportChange('Password', 'user password has changed');
+             return 1;
+        } else {
+            return;
+        }
     } else {
         $self->base->log(LA_ERROR, "Permission denied for %s to change its password",
@@ -623,4 +663,21 @@
 }
 
+=head2 ReportChange($changetype, $message, @args)
+
+Possible per database way to log changes
+
+=cut
+
+sub ReportChange {
+    my ($self, $changetype, $message, @args) = @_;
+
+    $self->base->ReportChange(
+        $self->type,
+        $self->id,
+        $self->Iid,
+        $changetype, $message, @args
+    )
+}
+
 1;
 
Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm	(revision 1286)
@@ -637,4 +637,22 @@
 }
 
+sub ReportChange {
+    my ($self, $otype, $name, $ref, $changetype, $message, @args) = @_;
+
+    my $sth = $self->db->prepare(q{
+        INSERT into objectslogs (ikey, otype, name, changetype, username, message)
+        VALUES (?,?,?,?,?,?)
+        });
+
+    $sth->execute(
+        $ref,
+        $otype,
+        $name,
+        $changetype,
+        $self->user || '@Console',
+        sprintf($message, @args),
+    );
+}
+
 =head2 getobjectlogs($otype, $name)
 
Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm	(revision 1286)
@@ -143,4 +143,5 @@
     my ($self, %data) = @_;
     my %fdata;
+    my $res = 0;
     foreach my $attr (keys %data) {
         $attr =~ /^site$/ and do {
@@ -161,6 +162,8 @@
     }
     if  (keys %fdata) {
-        $self->SUPER::set_fields(%fdata);
+        $res += $self->SUPER::set_fields(%fdata);
     }
+
+    $res;
 }
 
Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 1286)
@@ -169,5 +169,5 @@
                 next;
             }
-            $self->_set_group_members($data{$attr});
+            $res += $self->_set_group_members($data{$attr});
             next;
         };
Index: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
===================================================================
--- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm	(revision 1285)
+++ trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm	(revision 1286)
@@ -129,4 +129,6 @@
 }
 
+sub Iid { $_[0]->_get_ikey }
+
 sub _get_ikey {
     my ($class, $base, $id) = @_;
@@ -179,15 +181,4 @@
 
     my $obj = $class->new($base, $id);
-    $obj->objectlog('Create', 'Object created');
-    foreach (keys %first) {
-        my $attr = $obj->attribute($_);
-        $obj->objectlog('Attribute', '%s set to %s', $_, (
-                defined($data{$_}) 
-                ? (ref $data{$_}
-                    ? join(', ', @{ $data{$_} })
-                    : $data{$_})
-                : '(none)'))
-            if ($attr->{notify});
-    }
     $obj->set_fields(%second);
 
@@ -200,5 +191,4 @@
     my $obj = $base->get_object($class->type, $id)
         or return;
-    $obj->objectlog('Delete', 'Object deleted');
 
     my $sthd = $base->db->prepare_cached(
@@ -215,10 +205,4 @@
     my ($class, $base, $id, $newid) = @_;
 
-    {
-        my $obj = $base->get_object($class->type, $id)
-            or return;
-        $obj->objectlog('Rename', 'Object rename to %s', $newid);
-    }
-
     my $sthr = $base->db->prepare_cached(
         sprintf(
@@ -238,9 +222,4 @@
     }
 
-    {
-        my $obj = $base->get_object($class->type, $newid)
-            or return;
-        $obj->objectlog('Rename', 'Object renamed from %s', $id);
-    }
     1;
 }
@@ -471,16 +450,4 @@
 
     delete($self->base->{__cache}{"_" . $self->type}{$self->id});
-    $self->objectlog('Update', 'Attributes %s where updated', join(', ', @updated_attributes))
-        if(@updated_attributes);
-    foreach (@updated_attributes) {
-        my $attr = $self->attribute($_);
-        $self->objectlog('Attribute', '%s set to %s', $_, (
-                defined($data{$_}) 
-                ? (ref $data{$_}
-                    ? join(', ', @{ $data{$_} })
-                    : $data{$_})
-                : '(none)'))
-            if ($attr->{notify});
-    }
     scalar(@updated_attributes);
 }
@@ -546,5 +513,5 @@
                 $self->id
             );
-            $self->objectlog('Password', 'user password has changed%s', ($asymencrypted ? ' and stored using internal key' : ''));
+            $self->ReportChange('Password', 'Password stored using internal key');
             return 1;
         }
@@ -749,26 +716,4 @@
 }
 
-=head2 objectlog
-
-=cut
-
-sub objectlog {
-    my ($self, $changetype, $message, @args) = @_;
-
-    my $sth = $self->base->db->prepare(q{
-        INSERT into objectslogs (ikey, otype, name, changetype, username, message)
-        VALUES (?,?,?,?,?,?)
-    });
-
-    $sth->execute(
-        $self->_get_ikey,
-        $self->type,
-        $self->id,
-        $changetype,
-        $self->base->user || '@Console',
-        sprintf($message, @args),
-    );
-}
-
 1;
 
