Dave Warnock wrote:
If TG has some sort of require option that could be invoked early, then
you could use a different invocation to require the version of TG that
you want to use.  This would be a nice feature for the scripts that
easy_install installs in general -- right now they require a fixed
version, but if they (say) checked an environmental variable for a
version override that would be cool.  Then you could support multiple
versions running at once (each in its own process, of course).


Yes, please. Should I create a ticket?

Well... I'm not sure what the right project would be. Obviously you can for TG, but I think the change should really happen in setuptools.

I think the patch would probably be simple. There's two wrappers -- one from the standard distutils method, and one from the console_scripts entry point. The one TurboGears uses looks like:

#!/usr/local/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'TurboGears==0.8a1dev-r39','console_scripts','tg-admin'
__requires__ = 'TurboGears==0.8a1dev-r39'
import sys
from pkg_resources import load_entry_point

sys.exit(
load_entry_point('TurboGears==0.8a1dev-r39', 'console_scripts', 'tg-admin')()
)


Just change that so it looks like:

#!/usr/local/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'TurboGears==0.8a1dev-r39','console_scripts','tg-admin'
import sys, os
__requires__ = os.environ.get('TURBOGEARS_REQUIRE', 'TurboGears==0.8a1dev-r39')
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point(__requires__, 'console_scripts', 'tg-admin')()
)


I don't know that $TURBOGEARS_REQUIRE is the best name, but something like that. I'm not sure how easy it is to set environmental variables in Windows, but on Posix systems you'd then just need to do:

TURBOGEARS_REQUIRE='TurboGears==0.5' tg-admin ...

(And incidentally with Paste you'd do paster --plugin=TurboGears==0.5
serve ..., or include the version number in your app's install_requires,
or in your Paste Deploy configuration file.)


As per the blog discussion I think getting TurboGears working fully with
paste is important for deployment. I understand it requires 2 things

a) cherrypy change as per your ticket item 145
http://www.cherrypy.org/ticket/145 "Running multiple apps in one process"

Yes; from here a paste.app_factory entry point could be added to TurboGears and/or CherryPy, and/or new projects (ultimately the cleanest method is when a new project contains a native entry point).

b) integration of turbogears tg-admin into paste. It sounds as if this
is done by duplication rather than extension at the moment - can that
change so they stay synchronised automagically?

Well... the API for a paster command is fairly simple. You make an entry point of type paste.paster_command, and the object that the entry point points to has to be callable with one argument (the name that was used to invoke it, generally the entry point name) and returns an object with a .run(args) method, which returns a integer exit code, or raises paste.script.command.BadCommand. Oh, and they should also have a summary attribute, a (possible empty) description attribute, and a group_name attribute -- all used for the help display. So, I imagine a wrapper for the current TurboGears commands would be easy enough, and since it's just entry points it doesn't mean TurboGears will require PasteScript, just work with it.

Templates are another API, paste.paster_create_template. Template objects are also instantiated with their name, and have a method .run(output_dir, vars), where vars is a dictionary of extra arguments provided on the command line, plus two standard ones: 'package' and 'project'. For --list-templates they also have a name attribute and a summary attribute. And I suppose they should have a group_name and description attribute, but that's not used yet. Oh, and a .egg_plugins attribute, which is a list of plugins that are later enabled (it probably be ['TurboGears'], or maybe ['TurboGears', 'SQLObject']).

So I think it would be pretty easy to support both commands (tg-admin and paster) at once.


--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org

Reply via email to