This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Deform Autoneed README

A simple package to turn any deform requirements into Fanstatic resources and serve them.

Some ideas were taken from js.deform, but this package is in many ways its absolute opposite: It only serves whatever content deform ships with. Hence it should be compatible with any version of deform.

Note

Note: This package patches deforms render function the same way as js.deform does. If you don’t want that, you can include the rendering yourself.

Tested with the following deform/Python versions:
  • Python 2.7, 3.3, 3.6
  • deform 0.9.9
  • deform 2.0a.2
  • deform 2.0.3

It should be compatible with most fanstatic versions, including current stable 0.16 and future 1.0x.

This package should also work with future versions of deform that are somewhat API-stable. Should be framework agnostic and compatible with anything that Fanstatic works on. (Any WSGI)

Simple usage

During startup procedure of your app, simply run:

from deform_autoneed import includeme
includeme()

Or if you use the Pyramid framework:

config.include('deform_autoneed')

This will populate the local registry with any resources that deform widgets might need, and patch deforms render function so they’re included automatically.

And that’s it!

Using registered resources in other pages

deform prior to 2 depends on jquery, while deform 2 depends on jquery and bootstrap. If you want any of these base packages in any other view that isn’t a form, simply:

from deform_autoneed import need_lib

need_lib('basic')

Basic means any base requirements of deform itself. You may also call other deform dependencies here. Essentially, you can use any key from deforms default resource registry in: deform.widget.default_resources.

Replacing a resource requirement

If you wish to replace a resource with something else, ResourceRegistry has a method for that. It will have an effect on everything that might depend on that resource.

Example:

deforms form.css is a registered requirement. We’ll replace it with out own css, where our_css is a fanstatic resource object.

resource_registry.replace_resource(‘deform:static/css/form.css’, our_css)

Note that replace_resource accepts either fanstatic.Resource“-objects or paths with package name, like ‘deform:static/css/form.css’ as arguments.

Registering a custom widgets resources

If you’re using any widgets/forms in deform that require non-standard plugins, you can register them within this package to include them.

First, create a Fanstatic library for your resources and an entry point in your setup.py. (See the Fanstatic docs for this)

from fanstatic import Library

my_lib = Library('my_lib', 'my/static')

Add your library to autoneed’s registry:

from deform_autoneed import resource_registry

resource_registry.libraries['my_package_name'] = my_lib

If you have structured your requirements the same way as in deform.widget.default_resources, and your directory for static resources is called static, you can call the method populate from resources to automatically create your package.

resource_registry.populate_from_resources(your_resources)

If not, you can simply add the requirements using the method create_requirement_for.

resource_registry.create_requirement_for('my_special_widget',
                                         ['my_package_name:my/static/css/cute.css', 'my_package_name:my/static/js/annoying.js'],
                                         )

In other words, this example had the directory layout, where the static directory is the base of your fanstatic library.

  • my_package_name/
    • my/
      • static/
        • css/
        • js/

And the custom widget will require something called ‘my_special_widget’. (See the deform docs on custom widgets)

After this, your dependencies will be included automatically whenever deform needs them.

Bugs, contact etc…

Changelog

0.2.3b (2017-02-08)

  • Fixes for Windows paths. While windows isn’t tested and maintained, it should work now. [sassur]

0.2.2b (2014-04-08)

  • Resource dependencies consider the order deform list them. A widget requirement with several listed resources will have them depend on each other in order.

0.2.1b (2014-04-08)

  • NOTE: remove_resources changed to remove_resource - it only accepts one resource now.
  • Replacing resources may require to replace dependencies as well. This is now the default option for replace_resource and remove_resource.

0.2b (2014-03-25)

  • New methods to interact and replace resources.
  • ResourceRegistry objects now keep track of fanstatic.Resources in ResourceRegistry.requirements, rather than file paths.
  • create_requirement_for now figures out proper paths from fanstatic libraries, so just specify proper package paths like: package_name:some/dir/with/file.js.

0.1b (2014-03-21)

  • Initial version
Release History

Release History

0.2.3b0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
deform_autoneed-0.2.3b0.tar.gz (10.1 kB) Copy SHA256 Checksum SHA256 Source Feb 8, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting