Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > AOP and metaclasses

Reply
Thread Tools

AOP and metaclasses

 
 
Santiago Aguiar
Guest
Posts: n/a
 
      02-20-2004
Im trying to use AOP techniques on python but, even if I understand
the idea behind metaclasses, I cant find a way to use AOP in a dynamic
way.

What im trying to do is to weave an aspect to a class at runtime, but
i don't want to include any special code or definition in the class
itself. Also, i want to do
it just for some particular classes. Is there any way to do this?

I know its possible to apply an aspect to all the classes by
redefining __metaclass__, and that I can do the same with a single
class by assigning to __metaclass__ inside the class definition.
However, I want to avoid the last step, so i can apply the aspect to
any class.

thanks!!

saludos! santiago.
 
Reply With Quote
 
 
 
 
Shalabh Chaturvedi
Guest
Posts: n/a
 
      02-20-2004
Santiago Aguiar wrote:
> I know its possible to apply an aspect to all the classes by
> redefining __metaclass__, and that I can do the same with a single
> class by assigning to __metaclass__ inside the class definition.
> However, I want to avoid the last step, so i can apply the aspect to
> any class.


If one class has a __metaclass__ inside its definition, its subclasses will
use the same metaclass (unless they have another __metaclass__ in their
defintion). So you could define one class and use it as a base for the
specific classes that you want to affect.

--
Shalabh
 
Reply With Quote
 
 
 
 
John Roth
Guest
Posts: n/a
 
      02-20-2004
"Santiago Aguiar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Im trying to use AOP techniques on python but, even if I understand
> the idea behind metaclasses, I cant find a way to use AOP in a dynamic
> way.
>
> What im trying to do is to weave an aspect to a class at runtime, but
> i don't want to include any special code or definition in the class
> itself. Also, i want to do
> it just for some particular classes. Is there any way to do this?
>
> I know its possible to apply an aspect to all the classes by
> redefining __metaclass__, and that I can do the same with a single
> class by assigning to __metaclass__ inside the class definition.
> However, I want to avoid the last step, so i can apply the aspect to
> any class.
>
> thanks!!
>
> saludos! santiago.


I believe there is at least one AOP project out there somewhere.
I don't think you want to use metaclasses, though. If I wanted
to do that, I'd look at using descriptors, and installing them at
run time when I found I wanted to do the cut.

However, I'm not a big fan of AOP. I got my taste of intercepting
someone else's entry points in the '70s when I was hacking MVS.

John Roth


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AOP and pep 246 Rustom Mody Python 13 11-13-2007 05:38 PM
AOP and debugging Twisted Java 0 03-01-2006 11:51 AM
Regarding AOP - Performance and Security Ravi Shankar Nair Java 3 12-21-2005 04:18 PM
AOP and Ruby Luís Miguel Lourenço Ruby 4 05-24-2005 10:20 PM
[ANN] Nitro + Og 0.16.0, AOP, TDD, Plain CGI, Code refactoring and more George Moschovitis Ruby 0 04-18-2005 07:54 AM



Advertisments