Why not just add the google app engine lib subdirectories to your python path?<br><br><br><div class="gmail_quote">On Tue, Aug 3, 2010 at 3:09 AM, Jean-Michel Pichavant <span dir="ltr"><<a href="mailto:jeanmichel@sequans.com">jeanmichel@sequans.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">samwyse wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm writing for the Google app engine and have stubbed my toe yet<br>
again on a simple obstacle. Non-trivial app engines programs require<br>
the import of several modules that aren't normally in my PYTHONPATH.<br>
I'd like to be able to test my code outside of the app engine<br>
framework. I've tried several solutions in the past that worked but<br>
weren't particularly elegant or portable. Now I've had a new idea.<br>
Here's my latest attempt:<br>
<br>
import os, re<br>
if __name__ == '__main__':<br>
pass<br>
else<br>
from google.appengine.ext import webapp<br>
register = webapp.template.create_template_register()<br>
<br>
This works great, except my code makes use of the resister object in<br>
several places, like this:<br>
<br>
register.filter(emptylines)<br>
<br>
Fortunately, I don't need the functionality of the object, I just want<br>
something that won't generate an error when I use it. So, what is the<br>
quickest way to to create such an object (replacing the 'pass' in my<br>
first snippet). My solution is this:<br>
<br>
class C:<br>
def filter(self, *args, **kwds):<br>
pass<br>
register = C()<br>
<br>
but it seems like I should be able to do something "better", as<br>
measured by lines of code, faking more than just a 'filter' method, or<br>
both. Any ideas? Thanks!<br>
<br>
</blockquote>
<br></div></div>
here is a class that accepts any method call without generating an error:<br>
<br>
class Stub(object):<br>
@staticmethod<br>
def stub(*arg, **kwarg):<br>
pass<br>
def __getattribute__(self, name):<br>
return Stub.stub<br>
<br>
<br>
s = Stub()<br>
s.foo('bar')<br>
s.bar<br>
s.bar('', '', 5)<br><font color="#888888">
<br>
<br>
JM</font><div><div></div><div class="h5"><br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>