Project

General

Profile

« Previous | Next » 

Revision 0fd15b39

Added by Marc Dequènes about 14 years ago

  • ID 0fd15b392cf05936d1405d5129b464db7e11fa20

[fix] don't crash when a hook crash (closes #37)

View differences:

lib/ldap_shadows/elements/object.rb
end
def check_hooks_before(action)
case action
when :save
if self.new_entry?
self.class.hook_before_create(self)
else
self.class.hook_before_modify(self)
end
when :delete
self.class.hook_before_delete(self)
end
# TODO: move this in the LdapAspect class
self.aspects.each do |aspect_name, aklass|
begin
case action
when :save
if self.new_entry?
aklass.hook_before_create(self)
self.class.hook_before_create(self)
else
aklass.hook_before_modify(self)
self.class.hook_before_modify(self)
end
when :delete
aklass.hook_before_delete(self)
self.class.hook_before_delete(self)
end
rescue
raise PreProcessingError, _("Hook before action on object failed: %s") % $!
end
# TODO: move this in the LdapAspect class
self.aspects.each do |aspect_name, aklass|
begin
case action
when :save
if self.new_entry?
aklass.hook_before_create(self)
else
aklass.hook_before_modify(self)
end
when :delete
aklass.hook_before_delete(self)
end
rescue
raise PreProcessingError, _("Hook before action on aspect '%s' failed: %s") % [aspect_name, $!]
end
end
end
......
def check_hooks_after(action)
# TODO: move this in the LdapAspect class
self.aspects.each do |aspect|
aklass = self.class.shadow.get_aspect(aspect)
next if aklass.nil?
begin
aklass = self.class.shadow.get_aspect(aspect)
next if aklass.nil?
case action
when :save
if self.new_entry?
aklass.hook_after_create(self)
else
aklass.hook_after_modify(self)
end
when :delete
aklass.hook_after_delete(self)
end
rescue
raise PreProcessingError, _("Hook after action on aspect '%s' failed: %s") % [aspect_name, $!]
end
end
begin
case action
when :save
if self.new_entry?
aklass.hook_after_create(self)
self.class.hook_after_create(self)
else
aklass.hook_after_modify(self)
self.class.hook_after_modify(self)
end
when :delete
aklass.hook_after_delete(self)
end
end
case action
when :save
if self.new_entry?
self.class.hook_after_create(self)
else
self.class.hook_after_modify(self)
self.class.hook_after_delete(self)
end
when :delete
self.class.hook_after_delete(self)
rescue
raise PreProcessingError, _("Hook after action on object failed: %s") % $!
end
end

Also available in: Unified diff