<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 06-12-2010 12:08, Ben Finney wrote:
<blockquote cite="mid:87aakj17m6.fsf@benfinney.id.au" type="cite">
<pre wrap="">Stef Mientki <a class="moz-txt-link-rfc2396E" href="mailto:stef.mientki@gmail.com"><stef.mientki@gmail.com></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">I would like to know if a class definition has a decorator,
</pre>
</blockquote>
<pre wrap="">
I'm not sure what this question means.
Applying a decorator to a class definition produces a normal class.
Classes don't “have” decorators; classes can be returned by a decorator
function, but AFAIK the resulting class doesn't “have” the decorator in
any sense.
</pre>
<blockquote type="cite">
<pre wrap="">is that possible ?
</pre>
</blockquote>
<pre wrap="">
The return value of a decorator isn't special in any way, AFAIK.
Any function can return a class object or a function object, and any
function can be used as a decorator.
The only thing that makes a function a decorator is how it is used in
the code; but it doesn't leave a trace that I know of.
Now, what is it you're trying to do? Perhaps there's a better solution
we can come up with.
</pre>
</blockquote>
Thanks Ben,<br>
here some more explanation.<br>
<br>
I've a number of (dynamic) applications,<br>
launched from a central wrapper.<br>
All these modules have a class "Start", which launches the
application and embeds them in the wrapper application.<br>
<br>
<tt>Module 1:<br>
class Start ():<br>
....<br>
<br>
Module 2:<br>
@auth<br>
class Start ():<br>
...<br>
</tt><br>
When the wrapper application is started, it looks for all dynamic
modules (without importing them),<br>
and list these application in a hierarchical tree.<br>
In the above axmple,<br>
I would like to know that the class "Start" in Module 2 has the
decorator "Auth", <b>without importing the module</b>,<br>
(so depending on the user logged in, I can decide to add or not add
the module to the hierarchical tree).<br>
<br>
thanks,<br>
Stef Mientki<br>
<br>
<br>
<br>
<br>
</body>
</html>