Skip to main content

About switchboard-tg2

switchboard-tg2 provides an easy way to plug Switchboard, a feature flipper library, into TurboGears2 applications.

Installing

switchboard-tg2 can be installed both from pypi:

easy_install switchboard-tg2

should just work for most of the users.

Using switchboard-tg2

In your application config/app_cfg.py import plug:

from tgext.pluggable import plug

Then at the end of the file call plug with switchboard-tg2:

plug(base_config, 'switchboard_tg2')

You will be able to access Switchboard’s admin UI at http://localhost:8080/switchboard.

You will also need to configure Switchboard’s access to memcached and MongoDB. By default Switchboard attempts to connect to both of these services on localhost and on the default ports. If it fails to connect it will fall back to in-memory equivalents and display warning messages in the admin UI.

While running with the in-memory mode enabled is fine for getting started quickly, please do not run in production in this mode!

Getting Started - An Example

The switchboard-tg2 code contains an example TurboGears 2 application, modified to use Switchboard. The application is a quickstart application and the only changes made to it where to setup Switchboard. You’ll find the application in the ‘example’ directory. Here’s how Switchboard was added to the app:

  1. Add the plug call to app_cfg.py:

    from tgext.pluggable import plug
    ...
    plug(base_config, 'switchboard_tg2')
  2. Import Switchboard’s operator and use it to optionally display a flash message from the root.py controller, as an example of using Switchboard in Python code:

    from switchboard import operator
    ...
    if operator.is_active('hello_world'):
        flash('Hello World')
  3. Next, we want to pass the operator off to the template so that we can also use it there. Again, in the root.py controller:

    return(page='index', operator=operator)
  4. Finally we can use the operator in the index.html template to make various parts of the page turn on or off:

    <py:if test="operator.is_active('getting_started')">
    ...
    </py:if>

One thing to note: the template demonstrates the use of parent/child switches. The getting_started switch is the parent switch. Any switch prefixed with getting_started: will be a child. Children inherit conditions from their parents and can add conditions of their own.

To see all of these switches in action: run paster serve development.ini in the example directory and point your browser to http://localhost:8080/. Once you load the index page, all of the switches encountered will be automagically created within Switchboard. When you pull up the admin UI at http://localhost:8080/switchboard/, you’ll see the hello_world and getting_started switches.

Set the getting_started switch to “Active for everyone” and reload the index page. Now reload the Switchboard admin and you should see several more of the child switches for the Getting Started section. These switches weren’t created because they weren’t even checked until their parent switch was turned on.

Play around with turning various switches on and off to see what impact it has on the index page. You can also try adding conditions to a switch to see what happens when a switch is only active under certain conditions.

Here’s a diff of all the changes made to the example app to change it from the stock quickstart app to a Switchboard-enabled app:

http://pastie.org/6634144

More information

You can find more information about Switchboard and how to use it in your code in the Switchboard docs.

Metadata

Release files for switchboard-tg2 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 switchboard-tg2 0.3
File Size Uploaded Provenance
switchboard-tg2-0.3.tar.gz 3.8 kB Without provenance Details

Release files / switchboard-tg2-0.3.tar.gz

Download URL switchboard-tg2-0.3.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
559e4d699eb90b62faed53a928bb24d9b7ea15ef714c271123bd2c2968cd8a26
BLAKE2b-256 checksum
How to use checksums
64ab048920550a50e6cb44e6cade55504a19bb93d282636ada1565ac0c72485f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for switchboard-tg2 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.

Release history Release notifications | RSS feed

This release

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