wikklytext, imp and google app engine

1 view
Skip to first unread message

chris...@gmail.com

unread,
Apr 7, 2009, 7:46:28 AM4/7/09
to WikklyText
GoogleAppEngine doesn't seem to like WikklyText's use of the imp
module , it thinks of it as a restricted module and throws an
ImportError when trying to compile wikklytext.plugins.

I was able to work around this problem with the included diff. This
works for me because I don't use any plugins (yet), but obviously is
not a great solution for people who do.

GAE is reasonably okay with __import__, so there's probably a way to
get the desired behavior without using imp.

This all came up while bringing the google app engine of TiddlyWeb up
to modern times. The wiki serializer now uses wikklytext for doing
some special magic to set the title bar of the browser (we go from
wikitext -> html -> plain text). The old version of TiddlyWeb on GAE
didn't do any wikklytext stuff so this issue was not exposed.

diff -u wikklytext/macro.py /Users/cdent/twappengine/wikklytext/
macro.py
--- wikklytext/macro.py 2008-08-30 17:03:30.000000000 +0100
+++ /Users/cdent/twappengine/wikklytext/macro.py 2009-04-07
12:32:53.000000000 +0100
@@ -319,7 +319,6 @@
return outnode

from boodebr.util import load_module
-from wikklytext.plugins import load_plugins

def call_macro(wcontext, name, elements):
"""
@@ -328,7 +327,11 @@

Returns list of elements that the macro returns. On error, will
raise WikError.
"""
- plugins = load_plugins(wcontext.plugin_dirs)
+ try:
+ from wikklytext.plugins import load_plugins
+ plugins = load_plugins(wcontext.plugin_dirs)
+ except ImportError:
+ plugins = []

func = None

@@ -374,8 +377,12 @@
}

# add names from __all__ in plugins as well
- plugins = load_plugins(wcontext.plugin_dirs)
- eglobals.update(plugins.embed)
+ try:
+ from wikklytext.plugins import load_plugins
+ plugins = load_plugins(wcontext.plugin_dirs)
+ eglobals.update(plugins.embed)
+ except ImportError:
+ pass

for k,v in eglobals.items():
wcontext.mod_embedded.__dict__[k] = v

Frank McIngvale

unread,
Apr 7, 2009, 9:27:44 AM4/7/09
to wikkl...@googlegroups.com
Chris,

Thanks for noticing that and sending a patch. I'll go ahead and apply that for 1.6. Like you say, there's probably a more GAE-friendly way to do plugins but this will serve as a stopgap for now.

I'm definitely interested in any other GAE issues you find. A long (maybe indefinitely long :-) goal is to get the full blown wiki running under GAE so any bug reports/patches will help that along.

thanks,
Frank
Reply all
Reply to author
Forward
0 new messages