473,466 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

AOP and metaclasses

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.
Jul 18 '05 #1
2 1658
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
Jul 18 '05 #2
"Santiago Aguiar" <sa***@netlabs.com.uy> wrote in message
news:9b**************************@posting.google.c 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
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephan Diehl | last post by:
I have a question about metaclasses: How would be the best way to "merge" different metaclasses? Or, more precisely, what is the best way to merge metaclass functionality? The idea is basicly...
3
by: Mike C. Fletcher | last post by:
Slides from my PyGTA presentation on Tuesday, focusing mostly on why/where you would want to use meta-classes, are available in PDF format: ...
27
by: Michele Simionato | last post by:
> Hello, my name is Skip and I am metaclass-unaware. I've been programming in > Python for about ten years and I have yet to write a metaclass. At first I > thought it was just that metaclasses...
4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
13
by: Jean-François Doyon | last post by:
Hello, I'm using MetaClasses to create classes. How do I make these new classes "globally" available? I probably just have to assign them to something magic, but I can't seem to figure out...
1
by: Hartmut Goebel | last post by:
Hi, I'm currently implementing a tool for auto-generating webforms from a desription file. The output should become a php-script, an asp-script, zope-formulator or such. Each if it may (or may...
2
by: Paul Morrow | last post by:
....that they warrant an entirely new syntax? It seems that they are very similar in a very significant way --- they alter the default behavior of something. IMO, it's not a stretch to say that...
0
by: Jan-Ole Esleben | last post by:
Hi! I've just posted a question about metaclasses in ZOPE on the ZOPE list, and one of the replies said that metaclasses (at least "painless" metaclasses) cannot be used without new-style...
1
by: Alan Isaac | last post by:
Forman's book is out of print. Is there a good substitute? Thanks, Alan Isaac
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.