[Reality] patch to make Imagination run
Ed Rahn
ed at lamedomain.net
Sun Mar 27 17:01:47 MST 2005
Attached is a patch updating the usage of zope.interfaces in Imagination. With these changes the demo in the sandbox now works.
Ed
-------------- next part --------------
Index: imagination/facets.py
===================================================================
--- imagination/facets.py (revision 179)
+++ imagination/facets.py (working copy)
@@ -24,7 +24,14 @@
for interfaceClass in interfaceClasses:
self.register([origInterface], interfaceClass, '', adapterFactory)
+def _hook(iface, ob, lookup=registry.lookup1):
+ factory = lookup(declarations.providedBy(ob), iface)
+ if factory is None:
+ return None
+ else:
+ return factory(ob)
+interface.adapter_hooks.append(_hook)
_nope = object()
class IReprable(Interface):
Index: imagination/wiring/web.py
===================================================================
--- imagination/wiring/web.py (revision 179)
+++ imagination/wiring/web.py (working copy)
@@ -12,7 +12,7 @@
from nevow import rend
from nevow.loaders import stan
from nevow.tags import *
-from nevow.livepage import handler, glue, literal
+from nevow.liveevil import handler, glue, literal
from nevow import entities
getinput = literal.getinput
Index: imagination/simdata.py
===================================================================
--- imagination/simdata.py (revision 179)
+++ imagination/simdata.py (working copy)
@@ -98,11 +98,11 @@
map[iface] = (map[iface][0], lazy(map[iface][1], kw))
return ThingTemplate(templateMap=map, order=order)
- def apply(self, method, *args, **kw):
+ def apply(self, methodClass, methodName, *args, **kw):
map = self.templateMap.copy()
order = self.order[:]
order.append(
- lazyApply(method.im_class, method.im_func.func_name, args, kw))
+ lazyApply(methodClass, methodName, args, kw))
return ThingTemplate(templateMap=map, order=order)
def copy(self):
Index: imagination/architecture.py
===================================================================
--- imagination/architecture.py (revision 179)
+++ imagination/architecture.py (working copy)
@@ -87,8 +87,9 @@
def iterImplementors(self, interface):
if self.closed:
- selfish = interface(self, default=None)
- if selfish is None:
+ try:
+ selfish = interface(self)
+ except TypeError:
return iter([])
return iter([selfish])
else:
Index: sandbox/simplemap.py
===================================================================
--- sandbox/simplemap.py (revision 179)
+++ sandbox/simplemap.py (working copy)
@@ -25,17 +25,17 @@
name="Gamma",
description=("This room is visible through a transparent door.")).new()
-passage = basic.Portal.apply(architecture.IExit.between, room, room2).fill(
+passage = basic.Portal.apply(architecture.IExit, 'between', room, room2).fill(
INoun, name="Fancy Passageway Between Alpha and Omega").new()
door = basic.Door.fill(
INoun, name="Door"
- ).apply(architecture.IExit.between, room2, room3).new()
+ ).apply(architecture.IExit, 'between', room3, room3).new()
door2 = basic.Door.fill(INoun, name="glass door"
).fill(
architecture.IExit, transparent=True).apply(
- architecture.IExit.between, room, room4).new()
+ architecture.IExit, 'between', room, room4).new()
book1 = basic.Book.fill(containment.ILocatable, location=room).fill(
More information about the Reality
mailing list