tg.devtools-2.0.2/ 0000755 0000765 0000765 00000000000 11240527554 021050 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/ 0000755 0000765 0000765 00000000000 11240527554 022707 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/.___init__.py 0000644 0000765 0000765 00000000270 11113340245 025221 0 ustar markramm-christensen markramm-christensen Mac OS X 2 ATTRC com.macromates.caret xR <[k0?'3/« tg.devtools-2.0.2/devtools/__init__.py 0000644 0000765 0000765 00000000000 11113340245 024773 0 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/commands/ 0000755 0000765 0000765 00000000000 11240527554 024510 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/commands/__init__.py 0000644 0000765 0000765 00000000000 11113340241 026570 0 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/commands/._migration.py 0000644 0000765 0000765 00000000273 11113340241 027253 0 ustar markramm-christensen markramm-christensen Mac OS X 2 ATTRC{ # # com.macromates.caret { column = 61; line = 10; } tg.devtools-2.0.2/devtools/commands/migration.py 0000644 0000765 0000765 00000003662 11113340241 027043 0 ustar markramm-christensen markramm-christensen """ TurboGears migration paster migrate command integrate sqlalchemy-migrate into TurboGears 2. To start a migration, run command:: $ paster migrate create And migrate command will create a 'migration' directory for you. With migrate command you don't need use 'manage.py' in 'migration' directory anymore. Then you could bind the database with migration with command:: $ paster migrate version_control Usage: .. parsed-literal:: paster migrate help paster migrate create paster migrate vc|version_control paster migrate dbv|db_version paster migrate v|version paster migrate manage [script.py] paster migrate test [script.py] paster migrate ci|commit [script.py] paster migrate up|upgrade [--version] paster migrate downgrade [--version] .. container:: paster-usage --version database's version number check http://code.google.com/p/sqlalchemy-migrate/wiki/MigrateVersioning for detail. """ from paste.script import command import os import ConfigParser from migrate.versioning.shell import main class MigrateCommand(command.Command): """Sqlalchemy migration""" max_args = 3 min_args = 1 summary = __doc__.splitlines()[0] usage = '\n' + __doc__ group_name = "TurboGears2" parser = command.Command.standard_parser(verbose=True) def command(self): ini = 'development.ini' sect = 'app:main' option = 'sqlalchemy.url' # get sqlalchemy.url config in app:mains curdir = os.getcwd() conf = ConfigParser.ConfigParser() conf.read(os.path.join(curdir, ini)) self.name = "migration" try: self.dburi = conf.get(sect, option, vars={'here':curdir}) except: print "you shold set sqlalchemy.url in development.ini first" print "The repository is '%s'\nThe url is '%s'"%(self.name, self.dburi) main(argv=self.args, url=self.dburi,repository=self.name, name=self.name) tg.devtools-2.0.2/devtools/commands/quickstart.py 0000644 0000765 0000765 00000021050 11153607757 027261 0 ustar markramm-christensen markramm-christensen """Quickstart command to generate a new project. TurboGears 2 uses Paste to create and deploy projects as well as create new controllers and their tests. Quickstart takes the files from turbogears.pastetemplates and processes them to produce a new, ready-to-run project. Create a new project named helloworld with this command:: $ paster quickstart helloworld You can use TurboGears2, Pylons, and WebHelper paster commands within the project, as well as any paster commands that are provided by a plugin, or you create yourself. Usage: .. parsed-literal:: paster quickstart [--version][-h|--help] [-p *PACKAGE*][--dry-run][-t|--templates *TEMPLATES*] [-s|--sqlalchemy][-o|--sqlobject][-a|--auth][-g|--geo] .. container:: paster-usage --version how program's version number and exit -h, --help show this help message and exit -p PACKAGE, --package=PACKAGE package name for the code --dry-run dry run (don't actually do anything) -t TEMPLATES, --templates=TEMPLATES user specific templates -s, --sqlalchemy use SQLAlchemy as ORM -a, --auth provide authentication and authorization support -g, --geo add GIS support """ import pkg_resources import re import optparse from paste.script import command from paste.script import create_distro import os import stat import sys beginning_letter = re.compile(r"^[^a-z]*") valid_only = re.compile(r"[^a-z0-9_]") class QuickstartCommand(command.Command): """Create a new TurboGears 2 project. Create a new Turbogears project with this command. Example usage:: $ paster quickstart yourproject or start project with authentication and authorization support:: $ paster quickstart -a yourproject """ version = pkg_resources.get_distribution('turbogears2').version max_args = 3 min_args = 0 summary = __doc__.splitlines()[0] usage = '\n' + __doc__ group_name = "TurboGears2" name = None auth = None geo = False package = None svn_repository = None sqlalchemy = False sqlobject = False templates = "turbogears2" dry_run = False no_input = False parser = command.Command.standard_parser(quiet=True) parser = optparse.OptionParser( usage="%prog quickstart [options] [project name]", version="%prog " + version) parser.add_option("-a", "--auth", help='add authentication and authorization support', action="store_true", dest="auth") parser.add_option("-g", "--geo", help="add GIS support", action="store_true", dest="geo") parser.add_option("-p", "--package", help="package name for the code", dest="package") parser.add_option("-r", "--svn-repository", metavar="REPOS", help="create project in given SVN repository", dest="svn_repository", default=svn_repository) parser.add_option("-s", "--sqlalchemy", help="use SQLAlchemy as ORM", action="store_true", dest="sqlalchemy", default=True) parser.add_option("-t", "--templates", help="user specific templates", dest="templates", default=templates) parser.add_option("--dry-run", help="dry run (don't actually do anything)", action="store_true", dest="dry_run") parser.add_option("--noinput", help="no input (don't ask any questions)", action="store_true", dest="no_input") def command(self): """Quickstarts the new project.""" self.__dict__.update(self.options.__dict__) if not True in [self.sqlalchemy, self.sqlobject]: self.sqlalchemy = True if self.args: self.name = self.args[0] while not self.name: self.name = raw_input("Enter project name: ") package = self.name.lower() package = beginning_letter.sub("", package) package = valid_only.sub("", package) if package and self.no_input: self.package = package else: self.package = None while not self.package: self.package = raw_input( "Enter package name [%s]: " % package).strip() or package if not self.no_input: while self.auth is None: self.auth = raw_input( "Do you need authentication and authorization" " in this project? [yes] ") self.auth = dict(y=True, n=False).get( self.auth.lstrip()[:1].lower() or 'y') if self.auth is None: print "Please enter y(es) or n(o)." if self.auth: if self.sqlalchemy: self.auth = "sqlalchemy" else: print ('You can only use authentication and authorization' ' in a new project if you use SQLAlchemy. Please check' ' the repoze.what documentation to learn how to implement' ' authentication/authorization with other sources.') return # TODO: As far as I know, SQLObject has never been supported in # TG2 # self.auth = "sqlobject" else: self.auth = None self.name = pkg_resources.safe_name(self.name) env = pkg_resources.Environment() if self.name.lower() in env: print 'The name "%s" is already in use by' % self.name, for dist in env[self.name]: print dist return import imp try: if imp.find_module(self.package): print 'The package name "%s" is already in use' % self.package return except ImportError: pass if os.path.exists(self.name): print 'A directory called "%s" already exists. Exiting.' % self.name return command = create_distro.CreateDistroCommand("create") cmd_args = [] for template in self.templates.split(): cmd_args.append("--template=%s" % template) if self.svn_repository: cmd_args.append("--svn-repository=%s" % self.svn_repository) if self.dry_run: cmd_args.append("--simulate") cmd_args.append("-q") cmd_args.append(self.name) cmd_args.append("sqlalchemy=%s" % self.sqlalchemy) cmd_args.append("sqlobject=%s" % self.sqlobject) cmd_args.append("auth=%s" % self.auth) cmd_args.append("geo=%s" % self.geo) cmd_args.append("package=%s" % self.package) cmd_args.append("tgversion=%s" % self.version) # set the exact ORM-version for the proper requirements # it's extracted from our own requirements, so looking # them up must be in sync (there must be the extras_require named # sqlobject/sqlalchemy) """if self.sqlobject: sqlobjectversion = str(get_requirement('sqlobject')) cmd_args.append("sqlobjectversion=%s" % sqlobjectversion) if self.sqlalchemy: sqlalchemyversion = str(get_requirement('sqlalchemy')) cmd_args.append("sqlalchemyversion=%s" % sqlalchemyversion) """ command.run(cmd_args) if not self.dry_run: os.chdir(self.name) if self.sqlobject: # Create the SQLObject history directory only when needed. # With paste.script it's only possible to skip files, but # not directories. So we are handling this manually. sodir = '%s/sqlobject-history' % self.package if not os.path.exists(sodir): os.mkdir(sodir) try: if not os.path.exists(os.path.join(os.path.dirname( os.path.abspath(sodir)), '.svn')): raise OSError command.run_command('svn', 'add', sodir) except OSError: pass startscript = "start-%s.py" % self.package if os.path.exists(startscript): oldmode = os.stat(startscript).st_mode os.chmod(startscript, oldmode | stat.S_IXUSR) sys.argv = ["setup.py", "egg_info"] import imp imp.load_module("setup", *imp.find_module("setup", ["."])) # dirty hack to allow "empty" dirs for base, path, files in os.walk("./"): for file in files: if file == "empty": os.remove(os.path.join(base, file)) tg.devtools-2.0.2/devtools/pastetemplate.py 0000644 0000765 0000765 00000003250 11150150764 026124 0 ustar markramm-christensen markramm-christensen """Definitions for TurboGears quickstart templates""" from paste.script import templates from tempita import paste_script_template_renderer class TurboGearsTemplate(templates.Template): """ TurboGears 2 default paste template class """ _template_dir = 'templates/turbogears' template_renderer = staticmethod(paste_script_template_renderer) summary = 'TurboGears 2.0 Standard Quickstart Template' egg_plugins = ['PasteScript', 'Pylons', 'TurboGears2', 'tg.devtools'] vars = [ templates.var('sqlalchemy', 'use SQLAlchemy as ORM', default=True), templates.var('auth', 'use authentication and authorization support', default="sqlalchemy"), templates.var('geo', 'Include GIS support (True/False)', default='False'), ] def pre(self, command, output_dir, vars): """Called before template is applied.""" package_logger = vars['package'] if package_logger == 'root': # Rename the app logger in the rare case a project is named 'root' package_logger = 'app' vars['package_logger'] = package_logger template_engine = \ vars.setdefault('template_engine', 'genshi') if template_engine == 'mako': # Support a Babel extractor default for Mako vars['babel_templates_extractor'] = \ "('templates/**.mako', 'mako', None),\n%s#%s" % (' ' * 4, ' ' * 8) else: vars['babel_templates_extractor'] = '' if vars['geo'] == 'True': # Add tgext.geo as paster plugin vars['egg_plugins'].append('tgext.geo') tg.devtools-2.0.2/devtools/templates/ 0000755 0000765 0000765 00000000000 11240527554 024705 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/.___init__.py 0000644 0000765 0000765 00000000272 11113340245 027221 0 ustar markramm-christensen markramm-christensen Mac OS X 2 ATTRC " " com.macromates.caret { column = 5; line = 13; } tg.devtools-2.0.2/devtools/templates/__init__.py 0000644 0000765 0000765 00000005573 11113340245 027015 0 ustar markramm-christensen markramm-christensen """ Place to hold TurboGears built-in templates With 'paster quickstart' or 'paster create' command you can create a new TurboGears project which you can use as a basis for your own project. Let's take the command 'paster quickstart helloworld' for example. The generated directory structure is as follows:: - helloworld/ - helloworld/ - development.ini - setup.cfg - setup.py - test.ini The setup.py file is used to create a re-distributable Python package of your project called an egg. Eggs can be thought of as similar to .jar files in Java. The setup.cfg file contains extra information about your project. The sub 'helloworld' directory within the root 'helloworld' directory is where all your application specific code and files are placed. The sub directory looks like this:: - helloworld/ - config/ - controllers/ - lib/ - model/ - public/ - templates/ - tests/ - __init__.py - websetup.py The config directory contains the configuration options for your web application. The controllers directory is where your application controllers are written. Controllers are the core of your application where the decision is made on what data to load, and how to view it. The lib directory is where you can put code that is used between different controllers, third party code, or any other code that doesn't fit in well elsewhere. The models directory is for your model objects, if you're using an ORM this is where the classes for them should go. Objects defined in models/__init__.py will be loaded and present as model. YourObject inside your controllers. The database configuration string can be set in your development.ini file. The public directory is where you put all your HTML, images, Javascript, CSS and other static files. It is similar to the htdocs directory in Apache. The templates directory is where templates are stored. Templates contain a mixture of plain text and Python code and are used for creating HTML and other documents in a way that is easy for designers to tweak without them needing to see all the code that goes on behind the scenes. TurboGears 2 uses Genshi templates by default but also supports Mako, and jinja out of the box. Cheetah, Kid and any other template system you want can be easily used by writing a simple render function for them. The tests directory is where you can put controller and other tests. The controller testing functionality uses Nose and paste.fixture. The __init__.py file is present so that the helloworld directory can be used as a Python module within the egg. The websetup.py should contain any code that should be executed when an end user of your application runs the paster setup-app command described in Application Setup. If you're looking for where to put that should be run before your application is, this is the place. """ tg.devtools-2.0.2/devtools/templates/turbogears/ 0000755 0000765 0000765 00000000000 11240527554 027062 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/ 0000755 0000765 0000765 00000000000 11240527554 030603 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/__init__.py_tmpl 0000644 0000765 0000765 00000000066 11153607760 033753 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """The {{project}} package""" tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/ 0000755 0000765 0000765 00000000000 11240527554 032050 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/__init__.py_tmpl 0000644 0000765 0000765 00000000031 11153607757 035216 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/._app_cfg.py_tmpl 0000644 0000765 0000765 00000000273 11237676730 035303 0 ustar markramm-christensen markramm-christensen Mac OS X 2 ATTRe. # # com.macromates.caret { column = 45; line = 52; } tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/app_cfg.py_tmpl 0000644 0000765 0000765 00000004777 11237676730 035103 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """ Global configuration file for TG2-specific settings in {{project}}. This file complements development/deployment.ini. Please note that **all the argument values are strings**. If you want to convert them into boolean, for example, you should use the :func:`paste.deploy.converters.asbool` function, as in:: from paste.deploy.converters import asbool setting = asbool(global_conf.get('the_setting')) """ from tg.configuration import AppConfig import {{package}} from {{package}} import model from {{package}}.lib import app_globals, helpers base_config = AppConfig() base_config.renderers = [] base_config.package = {{package}} #Set the default renderer {{if template_engine == 'mako'}} base_config.default_renderer = 'mako' base_config.renderers.append('mako') {{elif template_engine == 'jinja'}} base_config.default_renderer = 'jinja' base_config.renderers.append('jinja') {{elif template_engine == 'genshi'}} base_config.default_renderer = 'genshi' base_config.renderers.append('genshi') # if you want raw speed and have installed chameleon.genshi # you should try to use this renderer instead. # warning: for the moment chameleon does not handle i18n translations #base_config.renderers.append('chameleon_genshi') {{endif}} {{if sqlalchemy}} #Configure the base SQLALchemy Setup base_config.use_sqlalchemy = True base_config.model = {{package}}.model base_config.DBSession = {{package}}.model.DBSession {{endif}} {{if auth == "sqlalchemy"}} # YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP base_config.sa_auth.cookie_secret = "ChangeME" # Configure the authentication backend base_config.auth_backend = 'sqlalchemy' base_config.sa_auth.dbsession = model.DBSession # what is the class you want to use to search for users in the database base_config.sa_auth.user_class = model.User # what is the class you want to use to search for groups in the database base_config.sa_auth.group_class = model.Group # what is the class you want to use to search for permissions in the database base_config.sa_auth.permission_class = model.Permission # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' {{endif}} tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/deployment.ini_tmpl_tmpl 0000644 0000765 0000765 00000005341 11173202655 037021 0 ustar markramm-christensen markramm-christensen # # {{project}} - TurboGears configuration # # The %(here)s variable will be replaced with the parent directory of this file # [DEFAULT] # WARGING == If debug is not set to false, you'll get the interactive # debugger on production, which is a huge security hole. debug = false email_to = you@yourdomain.com smtp_server = localhost error_email_from = paste@localhost [server:main] use = egg:Paste#http host = 0.0.0.0 port = 8080 [app:main] use = egg:{{project}} full_stack = true cache_dir = %(here)s/data beaker.session.key = {{package}} beaker.session.secret = ${app_instance_secret} app_instance_uuid = ${app_instance_uuid} # If you'd like to fine-tune the individual locations of the cache data dirs # for the Cache data, or the Session saves, un-comment the desired settings # here: #beaker.cache.data_dir = %(here)s/data/cache #beaker.session.data_dir = %(here)s/data/sessions {{if sqlalchemy}} # Specify the database for SQLAlchemy to use via # turbogears.database # %(here) may include a ':' character on Windows environments; this can # invalidate the URI when specifying a SQLite db via path name sqlalchemy.url = sqlite:///%(here)s/somedb.db sqlalchemy.echo = False {{endif}} # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* # Debug mode will enable the interactive debugging tool, allowing ANYONE to # execute malicious code after an exception is raised. #set debug = false # Logging configuration # Add additional loggers, handlers, formatters here # Uses python's logging config file format # http://docs.python.org/lib/logging-config-fileformat.html [loggers] keys = root, {{package_logger}}{{if sqlalchemy}}, sqlalchemy{{endif}}{{if auth == "sqlalchemy"}}, auth{{endif}} [handlers] keys = console [formatters] keys = generic # If you create additional loggers, add them as a key to [loggers] [logger_root] level = INFO handlers = console [logger_{{package_logger}}] level = INFO handlers = qualname = {{package_logger}} {{if sqlalchemy}} [logger_sqlalchemy] level = WARN handlers = qualname = sqlalchemy.engine # "level = INFO" logs SQL queries. # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) {{endif}} {{if auth == "sqlalchemy"}} # A logger for authentication, identification and authorization -- this is # repoze.who and repoze.what: [logger_auth] level = WARN handlers = qualname = auth {{endif}} # If you create additional handlers, add them as a key to [handlers] [handler_console] class = StreamHandler args = (sys.stderr,) level = NOTSET formatter = generic # If you create additional formatters, add them as a key to [formatters] [formatter_generic] format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s datefmt = %H:%M:%S tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/environment.py_tmpl 0000644 0000765 0000765 00000000414 11153607757 036030 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """WSGI environment setup for {{project}}.""" from {{package}}.config.app_cfg import base_config __all__ = ['load_environment'] #Use base_config to setup the environment loader function load_environment = base_config.make_load_environment() tg.devtools-2.0.2/devtools/templates/turbogears/+package+/config/middleware.py_tmpl 0000644 0000765 0000765 00000002432 11160337245 035571 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """WSGI middleware initialization for the {{project}} application.""" from {{package}}.config.app_cfg import base_config from {{package}}.config.environment import load_environment __all__ = ['make_app'] # Use base_config to setup the necessary PasteDeploy application factory. # make_base_app will wrap the TG2 app with all the middleware it needs. make_base_app = base_config.setup_tg_wsgi_app(load_environment) def make_app(global_conf, full_stack=True, **app_conf): """ Set {{project}} up with the settings found in the PasteDeploy configuration file used. :param global_conf: The global settings for {{project}} (those defined under the ``[DEFAULT]`` section). :type global_conf: dict :param full_stack: Should the whole TG2 stack be set up? :type full_stack: str or bool :return: The {{project}} application with all the relevant middleware loaded. This is the PasteDeploy factory for the {{project}} application. ``app_conf`` contains all the application-specific settings (those defined under ``[app:main]``. """ app = make_base_app(global_conf, full_stack=True, **app_conf) # Wrap your base TurboGears 2 application with custom middleware here return app tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/ 0000755 0000765 0000765 00000000000 11240527554 033151 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/__init__.py_tmpl 0000644 0000765 0000765 00000000113 11153607760 036312 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Controllers for the {{project}} application.""" tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/controller.template_tmpl 0000644 0000765 0000765 00000001244 11153607760 040127 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Sample controller module""" # turbogears imports from tg import expose #from tg import redirect, validate, flash # third party imports #from pylons.i18n import ugettext as _ #from repoze.what import predicates # project specific imports from {{package}}.lib.base import BaseController #from {{package}}.model import DBSession, metadata class SampleController(BaseController): {{if auth == "sqlalchemy"}} #Uncomment this line if your controller requires an authenticated user #allow_only = authorize.not_anonymous() {{endif}} @expose('{{package}}.templates.index') def index(self): return dict(page='index') tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/error.py_tmpl 0000644 0000765 0000765 00000002027 11160337245 035706 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Error controller""" from tg import request, expose __all__ = ['ErrorController'] class ErrorController(object): """ Generates error documents as and when they are required. The ErrorDocuments middleware forwards to ErrorController when error related status codes are returned from the application. This behaviour can be altered by changing the parameters to the ErrorDocuments middleware in your config/middleware.py file. """ @expose('{{package}}.templates.error') def document(self, *args, **kwargs): """Render the error document""" resp = request.environ.get('pylons.original_response') default_message = ("
We're sorry but we weren't able to process " " this request.
") values = dict(prefix=request.environ.get('SCRIPT_NAME', ''), code=request.params.get('code', resp.status_int), message=request.params.get('message', default_message)) return values tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/._root.py_tmpl 0000644 0000765 0000765 00000000270 11166762000 035750 0 ustar markramm-christensen markramm-christensen Mac OS X 2 ATTRe? com.macromates.caret xR <[k0?'3/« tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/root.py_tmpl 0000644 0000765 0000765 00000006643 11166762000 035545 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Main Controller""" from tg import expose, flash, require, url, request, redirect from pylons.i18n import ugettext as _, lazy_ugettext as l_ {{if auth == "sqlalchemy"}} from catwalk.tg2 import Catwalk from repoze.what import predicates {{endif}} from {{package}}.lib.base import BaseController from {{package}}.model import DBSession, metadata from {{package}}.controllers.error import ErrorController {{if auth == "sqlalchemy"}} from {{package}} import model from {{package}}.controllers.secure import SecureController {{endif}} __all__ = ['RootController'] class RootController(BaseController): """ The root controller for the {{project}} application. All the other controllers and WSGI applications should be mounted on this controller. For example:: panel = ControlPanelController() another_app = AnotherWSGIApplication() Keep in mind that WSGI applications shouldn't be mounted directly: They must be wrapped around with :class:`tg.controllers.WSGIAppController`. """ {{if auth == "sqlalchemy"}} secc = SecureController() admin = Catwalk(model, DBSession) {{endif}} error = ErrorController() @expose('{{package}}.templates.index') def index(self): """Handle the front-page.""" return dict(page='index') @expose('{{package}}.templates.about') def about(self): """Handle the 'about' page.""" return dict(page='about') {{if auth == "sqlalchemy"}} @expose('{{package}}.templates.authentication') def auth(self): """Display some information about auth* on this application.""" return dict(page='auth') {{endif}} {{if auth == "sqlalchemy"}} @expose('{{package}}.templates.index') @require(predicates.has_permission('manage', msg=l_('Only for managers'))) def manage_permission_only(self, **kw): """Illustrate how a page for managers only works.""" return dict(page='managers stuff') @expose('{{package}}.templates.index') @require(predicates.is_user('editor', msg=l_('Only for the editor'))) def editor_user_only(self, **kw): """Illustrate how a page exclusive for the editor works.""" return dict(page='editor stuff') @expose('{{package}}.templates.login') def login(self, came_from=url('/')): """Start the user login.""" login_counter = request.environ['repoze.who.logins'] if login_counter > 0: flash(_('Wrong credentials'), 'warning') return dict(page='login', login_counter=str(login_counter), came_from=came_from) @expose() def post_login(self, came_from=url('/')): """ Redirect the user to the initially requested page on successful authentication or redirect her back to the login page if login failed. """ if not request.identity: login_counter = request.environ['repoze.who.logins'] + 1 redirect(url('/login', came_from=came_from, __logins=login_counter)) userid = request.identity['repoze.who.userid'] flash(_('Welcome back, %s!') % userid) redirect(came_from) @expose() def post_logout(self, came_from=url('/')): """ Redirect the user to the initially requested page on logout and say goodbye as well. """ flash(_('We hope to see you soon!')) redirect(came_from) {{endif}} tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/secure.py_tmpl 0000644 0000765 0000765 00000002442 11160337245 036044 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Sample controller with all its actions protected.""" {{if auth == "sqlalchemy"}} from tg import expose, flash from pylons.i18n import ugettext as _, lazy_ugettext as l_ from repoze.what.predicates import has_permission #from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic #from dbsprockets.saprovider import SAProvider from {{package}}.lib.base import BaseController #from {{package}}.model import DBSession, metadata __all__ = ['SecureController'] class SecureController(BaseController): """Sample controller-wide authorization""" # The predicate that must be met for all the actions in this controller: allow_only = has_permission('manage', msg=l_('Only for people with the "manage" permission')) @expose('{{package}}.templates.index') def index(self): """Let the user know that's visiting a protected controller.""" flash(_("Secure Controller here")) return dict(page='index') @expose('{{package}}.templates.index') def some_where(self): """Let the user know that this action is protected too.""" return dict(page='some_where') {{else}} # This controller is only used when you activate auth. You can safely remove # this file from your project. {{endif}} tg.devtools-2.0.2/devtools/templates/turbogears/+package+/controllers/template.py_tmpl 0000644 0000765 0000765 00000001701 11160337245 036366 0 ustar markramm-christensen markramm-christensen # -*- coding: utf-8 -*- """Fallback controller.""" from {{package}}.lib.base import BaseController __all__ = ['TemplateController'] class TemplateController(BaseController): """ The fallback controller for {{project}}. By default, the final controller tried to fulfill the request when no other routes match. It may be used to display a template when all else fails, e.g.:: def view(self, url): return render('/%s' % url) Or if you're using Mako and want to explicitly send a 404 (Not Found) response code when the requested template doesn't exist:: import mako.exceptions def view(self, url): try: return render('/%s' % url) except mako.exceptions.TopLevelLookupException: abort(404) """ def view(self, url): """Abort the request with a 404 HTTP status code.""" abort(404) tg.devtools-2.0.2/devtools/templates/turbogears/+package+/i18n/ 0000755 0000765 0000765 00000000000 11240527554 031362 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/i18n/ru/ 0000755 0000765 0000765 00000000000 11240527554 032010 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/i18n/ru/LC_MESSAGES/ 0000755 0000765 0000765 00000000000 11240527554 033575 5 ustar markramm-christensen markramm-christensen tg.devtools-2.0.2/devtools/templates/turbogears/+package+/i18n/ru/LC_MESSAGES/+package+.po_tmpl 0000644 0000765 0000765 00000001541 11113340241 036674 0 ustar markramm-christensen markramm-christensen # Russian translations for ${package}. # Copyright (C) 2008 ORGANIZATION # This file is distributed under the same license as the ${package} project. # FIRST AUTHOR