[PEAK] MethodExporter examples don't seem to work

Victor Ng vng1 at mac.com
Sun Nov 2 01:33:13 EST 2003


Hi, I've been trying to use the MethodExporter metaclass but I can't 
seem to get the example code to run.  I'm using the sample code in 
method_exporter.py, but I always seem to get the following error:

   File "slap.py", line 28, in ?
     joe.slapFace("Thanks, I needed that!")
AttributeError: 'Person' object has no attribute 'slapFace'

Anyone knows what's going on?  I'm running a build of PEAK from CVS 
checked out today and I'm on Python 2.3.0 (MacPython - OSX)

vic

---

from peak.model.method_exporter import MethodExporter

class slappableFeature(object):

	__metaclass__ = MethodExporter

	message = "Ow, that hurts!"

	newVerbs = [ ('slap', "slap%(initCap)s") ]

	def slap(feature, self, extra):
		print "%s: %s (%s)" % (self.name, feature.message, extra)

class Person(object):

	def __init__(self,name):
		self.name = name

	class face(slappableFeature):
		message = "Watch out for my glasses!"

	class back(slappableFeature):
		pass

joe = Person('Joe')

# Prints: "Joe: Watch out for my glasses! (Thanks, I needed that!)"
joe.slapFace("Thanks, I needed that!")  # generates an error here

# Prints: "Joe: Ow, that hurts!  (Am I great or what?)"
joe.slapBack("Am I great or what?")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1235 bytes
Desc: not available
Url : http://www.eby-sarna.com/pipermail/peak/attachments/20031102/c3d2ec11/attachment.bin


More information about the PEAK mailing list