Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1181 (closed enhancement: fixed)

Opened 13 years ago

Last modified 11 years ago

Update TurboGears to CherryPy 3

Reported by: fredlin Owned by: kskuhlman
Priority: highest Milestone: 1.5
Component: CherryPy Version:
Severity: normal Keywords:
Cc: felix.schwarz@…, tcp@…

Description (last modified by jorge.vargas) (diff)

I tried to update TG to CP3 but not success, TG trunk is too tight with CherryPy? 2 for plenty of functions. It seems not possible to update to CP3 without broken the trunk.

Besides CP3, genshi porting is blocked from widgets, and some toolbox tools are depend on widgets, too. It seems not effective to "patch" the trunk. (I think those task worth to be '2.0' than '1.1')

But its easy to write the skeleton that mimic the basis of TurboGears.

Here's the quickstart project 'controllers.py' with CP3

from tgcore import controllers, expose

class Root(controllers.RootController):
    def index(self):
        return "Hello world"

template, database and config are not functional though


tgcore.zip Download (2.6 KB) - added by fredlin 13 years ago.
code support TG-CP3 "start_server", "controllers", "expose", "url", "redirect"
tgcore2.zip Download (5.8 KB) - added by fredlin 13 years ago.
support config.get
cp3tg.diff Download (13.2 KB) - added by fredlin 12 years ago.
workable patch for trunk (but many fuctions are breaken)

Change History

Changed 13 years ago by fredlin

code support TG-CP3 "start_server", "controllers", "expose", "url", "redirect"

Changed 13 years ago by fredlin

support config.get

Changed 12 years ago by fredlin

workable patch for trunk (but many fuctions are breaken)

comment:1 Changed 12 years ago by Felix.Schwarz

  • Cc felix.schwarz@… added

comment:2 Changed 12 years ago by jorge.vargas

  • Priority changed from normal to highest
  • Description modified (diff)

comment:3 Changed 12 years ago by max

(from alberto):

The main task needing work is migrating the tests to an independent testing framework to decouple them from CP2. I was thinking of paste.fixture for this but any framework that treats a TG app as an opaque WSGI app will be fine too. Once they all pass we can merge that branch into trunk and continue from there.

Before doing this, we need to implement a paste.app_factory entrypoint to build a WSGI app out of a TG/CP3 app so we can feed it to whatever fixture we use. I was thinking of implementing that as a bunch helper functions inside TG which handled common stuff (starting up TG's extensions, etc... those things implemented in turbogears/startup.py) and then calling them from inside the entry point inside the users application package. I'm sure you'll be familiar with this because it's very similar to what Pylons does in middleware.py

There's also work needed in order to adapt our config to CP3's. A Paste Deploy .ini config is not needed for now but it should be easy to use one once we provide the needed entry point.

Eventually I think it'll be a good idea to reimplement start-myapp.py as a simple wrapper around paste's loadapp (to load the app provided by the entry point) and loadserver (to load CP3's wsgi server). This setup should make trivial to integrate a TG/CP3 app into a bigger app and vice versa (the Pylons folks will probably love us once they can use CatWalk and Co. in their apps ;), not to mention that we'll have all existent middleware easily available to use in a TG app)

I did some experiements a while back implementing this so you might want to take ideas from there. the paste entrypoint is declared here:


However, ignore "Tree" because it's not really needed (and I had to hack it to make it treat SCRIPT_NAME in a way paths defined in CP3s config worked properly) or encouraged as dispatch to multiple apps can be done using URLMap or directly in a paste.deploy config. This ticket at CP can also help:


and this document too:


Take a look at the experiment at my repository because there's also some code integrating CP3's config that might help.

comment:4 Changed 12 years ago by fredlin

Here's a branch dedicate to this issue


comment:5 Changed 12 years ago by alberto

  • Milestone changed from 1.1 to __unclassified__

Batch moved into unclassified from 1.1 to properly track progress on the later

comment:6 Changed 12 years ago by alberto

  • Milestone changed from __unclassified__ to 1.1

comment:7 Changed 12 years ago by tcp

  • Cc tcp@… added

comment:8 Changed 12 years ago by alberto

  • Status changed from new to closed
  • Resolution set to fixed

TG trunk is already running on CP3. I'll close this coarse grained ticket to give room to finer grained tasks.


comment:9 Changed 11 years ago by kskuhlman

  • Status changed from closed to reopened
  • Type changed from defect to enhancement
  • Version trunk deleted
  • Resolution fixed deleted
  • Milestone changed from 1.1 to __unclassified__

I've gone through & cherry-picked the diffs from the old CP3 branch & reapplied them to a copy of 1.1.

I added some special sauce & now have a version that runs a quickstarted project and passes all but one of the core tg tests. I still need to clean it up a bit & fix identity & widgets, but I should have a version that's worth having another set of eyes look at soon.

Re-opening ticket & assigning to myself.

comment:10 Changed 11 years ago by kskuhlman

  • Status changed from reopened to new
  • Owner changed from anonymous to kskuhlman

comment:11 Changed 11 years ago by kskuhlman

  • Status changed from new to assigned
  • Milestone changed from __unclassified__ to 1.5

Created 1.5 branch & applied changes. All core tests pass, as well as all but one widget test.

Identity is still broken -- MonkeyDecodingFilter? needs fixing. A couple of other minor issues are documented in the changelog. Leaving ticket open until these are addressed.

comment:12 Changed 11 years ago by kskuhlman

  • Status changed from assigned to closed
  • Resolution set to fixed

All tests pass with 1.5 branch & CherryPy? 3.1. Quickstarted app works fine. Also, TurboGears no longer monkey-patches CherryPy? in any way.

From the changelog:

Changes ~

  • CherryPy? 3 integration. The CherryPy? changes that directly impact TurboGears are:
    • Filters have been replaced by Hooks & Tools.
      • static_filter.dir is now tools.staticdir.dir
      • session_filter.on has become tools.sessions
      • log_debug_info_filter is now log_debug_info_hook
      • base_url_filter is now tools.proxy
      • gzip_filter.mime_types is now tools.gzip.mime_types
    • simple_cookie renamed to just cookie on the request & response objects.
    • request.path is now request.path_info
    • cherrypy.lib.cptools.serveFile is now cherrypy.lib.static.serve_file
    • cherrypy.session is now an object instead of a dict.
    • Cherrypy now provides dummy request & response objects as simply cherrypy.request, cherrypy.response. The dummy versions of these have been removed from turbogears.testutil.
    • Requests now have a stage attribute to tell you where they are in the processing steps.
    • The reloader is no longer monkeypatched; CP3's reloader works just fine.
  • The deprecated features of testutil (create_request, etc) have been removed.
  • config is now seperated into server & app config. config.get is deprecated in favor of config.server.get or request.config when inside of a request.
  • Added visit toolbox to maintain compatability for log files.
  • Removed startup.get_object_trail, as it's no longer being used.
  • MonkeyDecodingFilter? has been removed. It's no longer needed now that the NestedVariablesHook? runs after cherrypy.tools.decode.
  • startup.SimpleWSGIServer is deprecated. Use cherrypy.wsgi.CPWSGIServer instead.

Closing ticket. Please create new tickets for any remaining issues.

comment:14 Changed 11 years ago by kskuhlman

  • Milestone changed from 1.5 to 1.6

comment:15 Changed 11 years ago by faide

  • Milestone changed from 1.6 to 1.5
Note: See TracTickets for help on using tickets.