I think for those TG1 users who are already using genshi and sa with
TG1, the portion requiring a rewrite is far less, probably 10-20%.
For instance. To provide a shortcut to identity in my template and
request context, here is what my base controller class looks like:
from tg import request, tmpl_context
class BaseController(TGController):
"""Base class for the root of a web application.
Your web application should have one of these. The root of
your application is used to compute URLs used by your app.
"""
def __call__(self, environ, start_response):
"""Invoke the Controller"""
# TGController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
tmpl_context.identity = request.environ.get
('repoze.who.identity')
request.identity = request.environ.get('repoze.who.identity')
return TGController.__call__(self, environ, start_response)
Maybe it's just me, but that doesn't seem like a huge change. The
identity object now hangs of the context of your request, which allows
for better multi-database support and solves threading issues that may
other wise crop up. And in fact, this code is part of the quickstart,
so you don't even have to figure it out yourself.
Kid->Genshi should be fairly straight forward. Genshi was designed as
a replacement for kid which is a) faster, and b) had better debugging
support. It achieves both of these goals.
Now, if you are switching from SO to SA, I feel your pain. I did this
back when SA was version 0.2 and I have never looked back. SA is
better supported, is more flexible, and has a HUGE following. Oh, and
by the way, the TG2 team is happy to include SO support if anyone
wants to dig in and write it, but the current members do not have the
resources to commit to a dying breed at this time.
TG2 _is_ a lot faster (although I have never experienced 2 p/sec with
TG1). With a complex genshi template, TW enabled pages are still
rendering at 33+p/sec. (Mac OS 10 2.4ghz, 4gb ram) The same pages
rendered as mako for your default template get roughly 120p/sec.
Simple pages rendered with Mako are looking about 400 p/sec. TG2 had
a "need for speed" sprint last month and we have a good understanding
of how our platform performs. Genshi is the bottleneck there...
2.1 will have better mako support, so for those looking to speed it up
a bit, you should start using mako now.
cheers.
-chris
On May 29, 12:20 pm, Daniel Fetchinson <[email protected]>
wrote:
> > It's late and I'm frustrated. Nonetheless I though I put a rant out there
> > (and
> > be it just to make me feel better):
>
> > <rant>
>
> > So I've been toying all day with TG2 and honestly I'm frustrated. Some
> > problems are to be expected, but a pretty much 80% rewrite of code certainly
> > is not.
> > Basically what I find is that so many things are majorly different or not
> > even
> > existant, that a migration from a TG1 app to a TG2 app is pretty much a
> > complete rewrite.
>
> > The whole "how SA is bound into things" requires a lot of rewrite. So
> > basically (besides the changes from SA 4.x to SA 5.x which the TG team can't
> > be blamed for - although I must say the SA team basically trashed the old
> > API
> > in favor of a new API - which in my case means going over 10k+ lines of
> > code - yet another reason why I hate ORMs) TG2 doesn't behave anywhere near
> > as TG1 did unless you trust SA to do the right thing with your database.
> > Reusing a currently available database is pretty much out of the question
> > unless you meddle a lot with the TG2 initialization (3 posts today alone on
> > the mailing list confirm that this is a problem for quite some people)
>
> > After you tackled the whole SA thing, you find out that the whole
> > auth/identity is nowhere near being as convenient or compatible as it was in
> > TG1. Now you have to fiddle with HTTP request headers you pull out of a
> > request object which may or may not be defined. Anyone who wrote an app that
> > relies on authentication is pretty much screwed right there. Registration
> > is
> > non-existant. Do you really expect anyone to push up a website where nobody
> > can sign up? I don't see a reason to use a framework like TG for static
> > pages
> > which don't require auth. Any simple PHP code can do that. The beauty of TG1
> > was that every page could be adapted to the view of the currently
> > authenticated user.
>
> > Auth used to be a simple
>
> > from turbogears import identity
>
> > if identity.current.anonymous:
> > do something
> > else:
> > uid=identity.current.user.user_id
> > whatever you do with uid
>
> > Now identitiy isn't even defined if the request is anonymous.Also grabbing
> > the
> > uid is something like requesting the uid from a dict which may or may not be
> > defined or may / may not contain a repoze.something object.
> > This is majorly inconvenient and will definitely keep people from adopting
> > TG2. I'm even considering rewriting my whole 500k+ lines application to
> > something different than TG altogether, simply because I basically rewrite
> > the whole thing on my way to TG2 and I'm afraid the next time around I will
> > touch another hundred thousand lines to go to TG2.x. TG1 sucks in terms of
> > speed (2 requests per second is nothing I would call "speed"), so my hope
> > was
> > that TG2 may remedy that. Currently I think it will take me weeks, if not
> > months to just get the basic homepage working with TG2. That's definitely
> > not
> > a migration path many people will adopt.
>
> > My current app has over 2000 references to identity. All of which need to be
> > rewritten with multiple lines of code. Big bummer right there. What was
> > wrong
> > with the old identity object that it's worth to dump it in favor of
> > something
> > more complicated which actually accomplishes less than what the old identity
> > did?
> > Can't there be an API consistent wrapper of some kind?
>
> > Compatibility is a big issue with TG2. IMHO it's probably not worth to do a
> > migration. One might just chose to rewrite the app using some other
> > framework
> > that shows more consistency.
>
> > I know everyone on the TG team invested a lot of effort into TG2 and I
> > certainly appreciate that. But I think to make TG really a framework of
> > choice for large apps requires a bit more backward compatibility to make it
> > a
> > viable choice. Particularly corporate size adopters like to see a clean
> > migration path between versions. Currently with TG the path is something
> > like "yeah, you can reuse about 20% of your code, the rest needs to be
> > rewritten - sorry about that".
>
> > </rant>
>
> I don't think it's surprising what you describe so there is no reason
> to be upset. I mean you can be upset but you cannot say it's
> unexpected. It has been said many times on this list and other places
> that tg2 is a big step away from tg1. It has been said that backward
> compatibility will not be maintained because of introducing new
> features. I don't think there is anything wrong with that, that is how
> projects evolve. What gave you the impression that the tg1 API will
> remain more or less the same in tg2? Maybe you just hoped for it but
> had no real reason for it because nobody promised anything like this?
> I suspect this is the case.
>
> I'm still using tg1 because for my needs it is perfect. I could use
> some tg2 features but I'm fully aware of the issues you describe
> concerning tg1 --> tg2 migration. So I will only migrate if the work
> of a nearly complete rewrite is worth it. At the moment it is not, so
> I'm sticking with tg1. Actually, there was word about tg 1.5 and/or a
> tg1 version that will be built on cherrypy 3. I guess the migration
> from the old tg1 to these newer tg1 versions will be much smoother and
> will be for sure worth it.
>
> Cheers,
> Daniel
>
> --
> Psss, psss, put it down! -http://www.cafepress.com/putitdown
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---