Package: sixfeetup.bowab
ContentsIntroductionExtra ModelsUsing the TemplateAPIGoogle AnalyticsCustomizing the TemplateAPIUsing the Recaptcha WidgetUsing the SpectrumColorPickerWidgetContributorsChangelog0.8 (xxxx-xx-xx)0.7IntroductionThis package is a collection of utility code to make building Pyramid applications
backed by SQLAlchemy easier. It includes:A TemplateAPI class to inject variables into all your templatesA Deform CSRF-validation schemaA Deform Recaptcha widgetSQLAlchemy DBSession and declarative_base stubsExtra ModelsIf you have models that you would like the maininitialize_dbscript to create,
they need to inherit fromsixfeetup.bowab.db.Base. Then add the following to your config:bowab.models =
    dotted.python.path.to.modelsUsing the TemplateAPIIf you would like to include thesixfeetup.bowab.api.TemplateAPIclass as is, you simply need to
include this in your Pyramid app configuration:config.include('sixfeetup.bowab')This will add an event subscriber to thepyramid.events.BeforeRenderevent. This means that all
templates will have access to anapivariable that represents theTemplateAPIinstance.Google AnalyticsThe TemplateAPI class supports extracting Google Analytics settings from the Pyramid settings registry. The following keys are supported:gaq.accountProperty ID from Googlegaq.allow_linkerhttp://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setAllowLinkergaq.domain_nameexplicit domain name to usegaq.single_pushboolean; use a push per setting, or one single pushTo use this in your project, updatebase.ptto include:<!-- Google Analytics -->
<tal:gaq condition="api.gaq">
    <tal:code replace="structure api.gaq.as_html()" />
</tal:gaq>Customizing the TemplateAPIOften, you will want to use thesixfeetup.bowab.api.TemplateAPIclass as a base for your own API
instances, since you may have extra variables that should be available to templates.To do this, you need to includesixfeetup.bowabas specified in the ‘Using the TemplateAPI’ section.Then, create a subclass within your project that inherits fromsixfeetup.bowab.api.TemplateAPI:from sixfeetup.bowab.api import TemplateAPI

class MyTemplateAPI(TemplateAPI):
    def __init__(self, request, rendering_val):
        super(MyTemplateAPI, self).__init__(request, rendering_val)
        # Any custom initalization

    def my_func(self):
        return 'my func'Then, in yourpaster.inifile, include the following:bowab.api_class = my_project.MyTemplateAPIMake sure thebowab.api_classvariable points to the full dotted path of your custom class. This class will
then be registered by thesixfeetup.bowabinclude process.Using the Recaptcha WidgetThe Recaptcha widget needs the private and public keys for your Recaptcha account.
These can be set in your config file using thebowab.recaptcha_private_keyandbowab.recaptcha_public_keyvalues, respectively.Using the SpectrumColorPickerWidgetThe spectrum color picker widget can be used to convert text inputs expecting
‘#’-prefixed hexidecimal values to a nice jquery-based color picker input.If the widget is initialized with a ‘default’ color value, that value will be
presented as a pallet swatch to ease returning to default.  If initialized with
a ‘color’ value, that will be the initial color displayed.Forms using the color picker widget will need to use thecolorpicker_registryin order to ensure that the color picker js and css files are found.  Alternatively,
the resources may be imported and loaded into a custom registry, or into the
deformdefault_resource_registry.If you have more than one color field in a form, and wish to have separate
values used forcoloranddefault, import thebuild_color_widgetfunction
which is suitable for use inside a defered widget generator.  (Seespeak_friend.forms.profiles.Domainfor an example).ContributorsDavid BlewettNolan BrubakerCris EwingChrissy WainwrightClayton ParkerChangelog0.8 (xxxx-xx-xx)0.7Initial implementation