« Return to Thread: set remoting gateway with AMF3

Re: PyAMF 0.4.2 - Code Server.Call.Failed is already registered / Django Integration

by Nick Joyce :: Rate this Message:

Reply to Author | View in Thread

Hi,

Is this in a production environment ?

I ask because it sounds like pyamf is being reloaded. If this is the  
case then this is a bug and a ticket should be created.

Cheers,

Nick

On 13 Jul 2009, at 15:48, Piero Campanelli wrote:

> Hi,
> when I use PyAMF 0.4.2 with Django I receive following error:
> Code Server.Call.Failed is already registered
> It seems problem is in the following:
> pyamf/__init__.py
> in method add_error_class(klass,code). If I comment these lines:
>   if code in ERROR_CLASS_MAP.keys():
>        raise ValueError('Code %s is already registered' % (code,))
> it works.
>
> def add_error_class(klass, code):
>    """
>    Maps an exception class to a string code. Used to map remoting  
> C{onStatus}
>    objects to an exception class so that an exception can be built to
>    represent that error::
>
>        class AuthenticationError(Exception):
>            pass
>
>    An example: C{add_error_class(AuthenticationError, 'Auth.Failed')}
>
>    @type code: C{str}
>
>    @raise TypeError: C{klass} must be a C{class} type.
>    @raise TypeError: Error classes must subclass the  
> C{__builtin__.Exception} class.
>    @raise ValueError: Code is already registered.
>    """
>    if not isinstance(code, basestring):
>        code = str(code)
>
>    if not isinstance(klass, (type, types.ClassType)):
>        raise TypeError("klass must be a class type")
>
>    mro = util.get_mro(klass)
>
>    if not Exception in mro:
>        raise TypeError('Error classes must subclass the  
> __builtin__.Exception class')
>
>    if code in ERROR_CLASS_MAP.keys():
>        raise ValueError('Code %s is already registered' % (code,))
>
>    ERROR_CLASS_MAP[code] = klass
>
>
> _______________________________________________
> PyAMF users mailing list - users@...
> http://lists.pyamf.org/mailman/listinfo/users

_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

 « Return to Thread: set remoting gateway with AMF3