[Soap-Python] Multiple decorators

azurIt azurit at pobox.sk
Fri Sep 30 13:50:31 CEST 2011


Maybe i misunderstood the usage (documentation is really horrible) but:
1.) yes, it is working without errors
2.) it's unusable

i created this test script:

===============

from decorator import decorator

def _do_something(func, *args, **kw):
	print "before call"
	result = func(*args, **kw)
	print "after call"
	return result

def my_decor(f):
	return decorator(_do_something, f)


class tests(ServiceBase):

	@my_decor
	@srpc(ComplexTypes.Integer, _returns=ComplexTypes.Integer)
	def testf(first):
		return first

===============

decorator was processed only once (on startup) and every call of testf() doesn't trigger it again.


azur


______________________________________________________________
> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
> Komu: <soap at python.org>
> Dátum: 30.09.2011 13:14
> Predmet: Re: [Soap-Python] Multiple decorators
>
>On 30.09.2011 11:33, Dieter Maurer wrote:
>> Burak Arslan wrote at 2011-9-29 17:37 +0300:
>>> On 29.09.2011 16:34, azurIt wrote:
>>>> is it somehow possible to use multiple decorators with @rpc/srpc ?
>>>>
>>>>
>>> Here's the magic from the rpclib.decorator module:
>>>
>>>      argcount = f.func_code.co_argcount
>>>      param_names = f.func_code.co_varnames[arg_start:argcount]
>>>
>>> if f is your decorator, the parameter names and numbers are going to be
>>> wrong. so no, use events. look at the relevant example in the source
>>> distribution and read the events section in the manual.
>> To define one own decorators, there is the great "decorator" package
>> (on PyPI). It makes it easy to implement signature preserving
>> decorators -- often important for things such as pipelining
>> several decorators.
>>
>
>hey, that just might work, thanks dieter. azur, could you try that?
>
>>
>> --
>> Dieter
>
>_______________________________________________
>Soap mailing list
>Soap at python.org
>http://mail.python.org/mailman/listinfo/soap
>


More information about the Soap mailing list