Time to move on to webapp2?

191 views
Skip to first unread message

Bert

unread,
Nov 13, 2011, 8:29:47 AM11/13/11
to tipfy
Hi,

I've got a relatively large application (lots of handlers, not lots of
users yet ) running on tipfy. I'm using multi-auth, deferred queue,
task queues, wtforms, sessionMiddleware, blobstore and jinja2
templating. I plan on using mapreduce and pipeline api for some new
functionality but I'm not sure if tipfy works out the box with these.
I also intend using full text search api (when it's finally release)
and who knows what other cool api's that get added in the future.

Tipfy hasn't got a new maintainer yet, so I fear that as time passes
I'll be stuck having to maintain my own custom built handlers for
interacting the new api's that google releases.

My questions:
*Should I bother porting my app to webapp2?
*Is there an easy way to do multi-auth with webapp2? I'm currently
using Twitter, Facebook and Google
*Will change handlers just be "find and replace"?
*Any other advice?

Thanks
Rob








Sam G

unread,
Nov 14, 2011, 3:55:43 PM11/14/11
to ti...@googlegroups.com
Hi Bert,

I've had to make the switchover in numerous apps now, and it's not that difficult.
Most of it can be done with find/replace:

- `tipfy.RequestHandler` needs to be `webapp2.RequestHandler` (obvs)
- `self.request.args.get` and `self.request.form.get` need to be replaced with `self.request.get`
- if you want to be returning responses like you did in tipfy, you'll need to override the `dispatch` method on RequestHandler, to return what your get/post method returns
- otherwise, you can write to the browser using `self.request.write` (note it's no longer `self.request.out.write`)
- your URL "Rules" must be converted to "Routes." The `endpoint` kwarg must be changed to `name`.
- you're gonna need to load jinja2 manually

I'm not sure about multiauth (I'm in an openid setup, which is working fine), but sessions are pretty easy with Webapp2.

As for MapReduce and Pipelines, they are framework agnostic. They work with Tipfy and Webapp2.

Honestly, I thought the switchover would be extremely painful... it turned out not to be. Webapp2 is fantastically written, and if you can't find something in the docs, it'll be in source comments.

Here are some resources to help you out further:

I'm actually writing a library right now that makes most of these changes easy. It's called AppTools... still in development (so use it at your own risk), but the source could give you some insights. Take a look at "core.py" especially - it's got a RequestHandler class that loads Jinja2, prepares a base template context, and does a few more useful things.


Good luck, and happy coding!
-sam

Bert

unread,
Nov 20, 2011, 4:20:05 AM11/20/11
to tipfy
Hey Sam,

Thanks a lot for the in-depth response.
I think I'll delay making the switch for now, but some time in the
future I'll def make the move and use the instructions you've
outlined. The reason I'm delaying is that it's working as it is right
now, and I think my time will be better spent on other functionality
for the app, or do you think it'll take a few hours to do and the move
is well worth it?
Thanks for apptools, I'll take a look.

Cheers
Rob


On Nov 14, 10:55 pm, Sam G <samuel.gam...@gmail.com> wrote:
> Hi Bert,
>
> I've had to make the switchover in numerous apps now, and it's not that
> difficult.
> Most of it can be done with find/replace:
>
> - `tipfy.RequestHandler` needs to be `webapp2.RequestHandler` (obvs)
> - `self.request.args.get` and `self.request.form.get` need to be replaced
> with `self.request.get`
> - if you want to be returning responses like you did in tipfy, you'll need
> to override the `dispatch` method on RequestHandler, to return what your
> get/post method returns
> - otherwise, you can write to the browser using `self.request.write` (note
> it's no longer `self.request.out.write`)
> - your URL "Rules" must be converted to "Routes." The `endpoint` kwarg must
> be changed to `name`.
> - you're gonna need to load jinja2 manually
>
> I'm not sure about multiauth (I'm in an openid setup, which is working
> fine), but sessions are pretty easy with Webapp2.
>
> As for MapReduce and Pipelines, they are framework agnostic. They work with
> Tipfy and Webapp2.
>
> Honestly, I thought the switchover would be extremely painful... it turned
> out not to be. Webapp2 is fantastically written, and if you can't find
> something in the docs, it'll be in source comments.
>

> Here are some resources to help you out further:http://blog.notdot.net/2011/10/Migrating-to-Python-2-7-part-1-Threadsafehttp://blog.notdot.net/2011/11/Migrating-to-Python-2-7-part-2-Webapp-...http://blog.notdot.net/2010/08/Using-BlobReader-wildcard-subdomains-a...


>
> I'm actually writing a library right now that makes most of these changes
> easy. It's called AppTools... still in development (so use it at your own
> risk), but the source could give you some insights. Take a look at
> "core.py" especially - it's got a RequestHandler class that loads Jinja2,
> prepares a base template context, and does a few more useful things.
>

> http://apptools.github.comhttp://www.github.com/sgammon/apptools

Reply all
Reply to author
Forward
0 new messages