You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(5) |
Nov
(13) |
Dec
(5) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(5) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
(9) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2003 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Frank T. <ft...@ne...> - 2001-10-27 04:12:48
|
I'm fairly new to AOP, and was thinking about implementing my own toolkit
for AOP and getting a project on SF for it, but I looked around and found
your project partly-started, so I thought I'd nudge in and see what's
happening.
I've looked at AspectJ, and I really like its model of doing things.
Consequently, I've started implementing a small black-box (run-time) aop
module for Python aspects. Just now I've looked at AspectR, and found
that it would be trivially easy to create something as advanced as AspectR
(read: not very advanced), but its not going to be hard to make it
decently (though not nearly as powerful as AspectJ, which has the
advantage of analyzing and recompiling code).
So, if you guys are still alive I'd like to start contributing my aspects
implementation to Pythius since you have front-end ideas for AOP, like
code-metrics (and that's great!). Aspects would be great to have on the
backend (obviously, or else you wouldn't be thinking of putting them with
Pythius).
I'm attaching my rough implementation test code. Below is some ideas on
the design I'm starting with:
class Pointcut:
|--MethodPointcut
|--SetattrPointcut
|-- ... (more pointcuts we provide)
Pointcut instantiations know about integrating into certain types of code.
For instance, the MethodPointcut knows how to put after/before hooks
around a method. You can instantiate a MethodPointcut with:
mypointcut = MethodPointcut(myclass.mymethod)
class Aspect:
|--MyLoggingAspect
|--MyOtherAspect
|--... (more aspects defined by user)
There is an abstract class Aspect, which users writing aspects subclass
from. Abstract methods include "after", "before", etc. Right now, my
implementation just passes these calls off to the Pointcut to install the
user-desired before/after code. The aspect gets "turned on" when an
object of the class is initialized (e.g., it happens in an object
constructor).
Below is an example user-defined aspect that used in the attached code:
class Logging(Aspect):
"""Just a sample test Aspect"""
def __init__(self):
addition = MethodPointcut(Student.add)
self.before(addition, self.log)
self.after(addition, self.log)
self.around(addition, self.bad_add)
def log(self, method, varargs, kwargs, full_kwargs):
print "logged %s being called with %s, %s, %s" \
% (method, varargs, kwargs, full_kwargs)
def notify(self, method, varargs, kwargs, full_kwargs, rv):
print "when %s came back, it gave %s" % (method, rv)
def bad_add(self, obj, a, b):
if a == b:
rv = a+b
print "Doubling stuff is easy; %s+%s=%s :)" % (a, b, rv)
return self.proceed()
rv = a+b+1
print ("I'm not very good at math, because I think %s+%s=%s :("
% (a, b, rv) )
return rv
As you can see, each "triggered" method (log, notify) takes parameters
that give it the environment which it is triggered in.
Current issues that are addressing me would be how to provide support for
combining contexts, like AspectJ does, handling something like "when
method X is called inside of method Y".
Everything I've thought of so far has been without much outside input, so
I'd love to discuss ideas, so let me know what you think.
--
Frank Tobin http://www.neverending.org/~ftobin/
|
|
From: Juergen H. <jh...@we...> - 2001-08-24 07:08:02
|
Hi! The lists are moving to sourceforge this weekend. I don't know whether I'm able to move your registrations, so you might have to subscribe again. Will keep you informed. Ciao, J=FCrgen |
|
From: Juergen H. <jh...@we...> - 2001-05-31 00:49:06
|
pydent is a tool that takes valid python source and indents it canonically
(i.e. using no TABs and 4 spaces per indent level). While doing this, it tries
to keep as much of the original formatting as possible, for example additional
indenting on continued lines. It also removes trailing whitespace, including
any whitespace on empty lines.
I tested it by running it over the standard lib of 2.0 (which surfaced some
funny formatting :), but it could use some heavy testing on as much source code
as possible. Get it from
http://sourceforge.net/cvs/?group_id=9021
(no tarball yet).
As an example, this is the diff for zipfile.py in the 2.0 standard lib after
running pydent over it (fixed some 2-space indents):
--- zipfile.bak Wed May 30 23:50:43 2001
+++ zipfile.py Thu May 31 00:05:04 2001
@@ -75,12 +75,12 @@
dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2]
dostime = dt[3] << 11 | dt[4] << 5 | dt[5] / 2
if self.flag_bits & 0x08:
- # Set these to zero because we write them after the file data
- CRC = compress_size = file_size = 0
+ # Set these to zero because we write them after the file data
+ CRC = compress_size = file_size = 0
else:
- CRC = self.CRC
- compress_size = self.compress_size
- file_size = self.file_size
+ CRC = self.CRC
+ compress_size = self.compress_size
+ file_size = self.file_size
header = struct.pack(structFileHeader, stringFileHeader,
self.extract_version, self.reserved, self.flag_bits,
self.compress_type, dostime, dosdate, CRC,
@@ -278,14 +278,14 @@
date_time = mtime[0:6]
# Create ZipInfo instance to store file information
if arcname is None:
- zinfo = ZipInfo(filename, date_time)
+ zinfo = ZipInfo(filename, date_time)
else:
- zinfo = ZipInfo(arcname, date_time)
+ zinfo = ZipInfo(arcname, date_time)
zinfo.external_attr = st[0] << 16 # Unix attributes
if compress_type is None:
- zinfo.compress_type = self.compression
+ zinfo.compress_type = self.compression
else:
- zinfo.compress_type = compress_type
+ zinfo.compress_type = compress_type
self._writecheck(zinfo)
fp = open(filename, "rb")
zinfo.flag_bits = 0x08
@@ -344,9 +344,9 @@
zinfo.file_offset = self.fp.tell() # Start of file bytes
self.fp.write(bytes)
if zinfo.flag_bits & 0x08:
- # Write CRC and file sizes after the file data
- self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size,
- zinfo.file_size))
+ # Write CRC and file sizes after the file data
+ self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size,
+ zinfo.file_size))
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
|