# Path: libxyz/core/utils.py
# def ustring(string, enc=None):
#     """
#     Return unicode string
#     """
# 
#     if isinstance(string, unicode):
#         return string
# 
#     if enc is None:
#         enc = xyzenc
# 
#     if not isinstance(string, str):
#         return unicode(string)
# 
#     # String
#     return string.decode(enc, 'replace')


import traceback
from libxyz.core.utils import ustring
        return True

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    def clear(self, event):
        """
        Clear all data assosiated with an event
        """

        self._data[event] = []

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    def dispatch(self, event, *args):
        """
        Sequentially run procedures registered with provided event
        """

        # No callbacks registered
        if event not in self._data or not self._data[event]:
            return False

        for proc in self._data[event]:
            try:
                proc(*args)
            except Exception, e:
                xyzlog.error(
                    _(u"Error running callback procedure for event %s") %
                    unicode(e))


# Path: libxyz/core/utils.py
# def ustring(string, enc=None):
#     """
#     Return unicode string
#     """
# 
#     if isinstance(string, unicode):
#         return string
# 
#     if enc is None:
#         enc = xyzenc
# 
#     if not isinstance(string, str):
#         return unicode(string)
# 
#     # String
#     return string.decode(enc, 'replace')


# Path: libxyz/core/hookmanager.py
import traceback
from libxyz.core.utils import ustring

        return True

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    def clear(self, event):
        """
        Clear all data assosiated with an event
        """

        self._data[event] = []

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    def dispatch(self, event, *args):
        """
        Sequentially run procedures registered with provided event
        """

        # No callbacks registered
        if event not in self._data or not self._data[event]:
            return False

        for proc in self._data[event]:
            try:
                proc(*args)
            except Exception, e:
                xyzlog.error(
                    _(u"Error running callback procedure for event %s") %
                    unicode(e))


                xyzlog.debug(ustring(traceback.format_exc()))