Skip to main content

About Pluggable Apps

tgext.pluggable permits to plug extensions and applications inside a TG projects much like the Django Apps.

tgext.pluggable IS STILL EXPERIMENTAL AND MIGHT CHANGE IN THE FUTURE

Installing

tgext.pluggable can be installed both from pypi or from bitbucket:

easy_install tgext.pluggable

should just work for most of the users

Plugging Apps

In your application config/app_cfg.py import plug:

from tgext.pluggable import plug

Then at the end of the file call plug for each pluggable application you want to enable (package_name must be already installed in your python environment):

plug(base_config, 'package_name')

The plug function accepts various optional arguments, for example if the plugged application exposes a controller you can mount it in a different place specifying a different appid:

plug(base_config, 'package_name', 'new_app_id')

Other options include:

  • plug_helpers (True/False) -> Enable helpers injection

  • plug_models (True/False) -> Enable models plugging

  • plug_controller (True/False) -> Mount pluggable app root controller

  • plug_bootstrap (True/False) -> Enable websetup.bootstrap plugging

  • plug_statics (True/False) -> Enable plugged app statics

  • rename_tables (True/False) -> Rename pluggable tables by prepending appid.

Partials

tgext.pluggables provides a bunch of utilities to work with partials. Partials in tgext.pluggable can be declared as a function or TGController subclass method that has an @expose decorator. Those partials can lately be rendered with:

${h.call_partial('module:function_name', arg1='Something')}

In the case of a class method:

${h.call_partial('module.Class:method', arg1='Something')}

The quickstarted pluggable application provides an example partial:

from tg import expose

@expose('plugappname.templates.little_partial')
def something(name):
    return dict(name=name)

which can be rendered using:

${h.call_partial('plugappname.partials:something', name='Partial')}

Replacing Templates

tgext.pluggable provides a function to replace templates. This is useful when you want to override the template that an application you plugged in is exposing. To override call replace_template inside your application config:

from tgext.pluggable replace_template

replace_template(base_config, 'myapp.templates.about', 'myapp.templates.index')

replace_template will work even with tgext.pluggable partials, but won’t work with templates rendered directly calling the render method.

Calls to replace_template must be performed before the application has started.

Creating Pluggable Apps

tgext.pluggable provides a quickstart-pluggable command to create a new pluggable application:

$ paster quickstart-pluggable plugtest
Enter package name [plugtest]:
...

The quickstarted application will provide an example on how to use models, helpers, bootstrap, controllers and statics.

In the previous example the pluggable application can be enabled inside any TurboGears using:

plug(base_config, 'plugtest')

After enabling the plugtest application you should run paster setup-app development.ini inside your TurboGears project to create the sample model. Then you can access the sample application page though http://localhost:8080/plugtest

Metadata

Release files for tgext.pluggable 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tgext.pluggable 0.0.3
File Size Uploaded Provenance Actions
tgext.pluggable-0.0.3.tar.gz 11.9 kB Without provenance Details for tgext.pluggable-0.0.3.tar.gz

Release files / tgext.pluggable-0.0.3.tar.gz

Download URL tgext.pluggable-0.0.3.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
64bbc9d76d79794e907148daf26785313588de7726255260613bc23e1e94973f
BLAKE2b-256 checksum
How to use checksums
a2cb4e7b10f06cd9113b1e511a7c53e2de90c69d9b397f81fc1d53cae7b051f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for tgext.pluggable 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page