deform and getting widget requirements from somewhere other than deform:static using pyramid and waitress server

25 views
Skip to first unread message

Jo G

unread,
Oct 19, 2016, 6:15:34 PM10/19/16
to pylons-discuss
Hi, so I have created my own deform widget which is an updated select2 (with help from this group) and rather than copy the .js and the .cs into the deform folder I would like to be able to serve them from elsewhere. I am using pyramid. and have several includes as well as my main pyramid app. bds.theme is one of those includes.

In the definition of my widget I have:

class Select2RemoteDataWidget(deform.widget.Select2Widget):
    template = 'bds.theme:templates/remotedataselect2-1.pt'
    requirements = (('deform', None), ('select2', '4.0.3'))
    readonly_template = 'bds.theme:templates/remotedataselect2-1-ro.pt
    url = ''

With just this I get a value error as there is no such requirement to be found in deform.

Then I added to the requirements in the init file of my pyramid application

    registry = deform.widget.ResourceRegistry(use_defaults=True)
    registry.set_js_resources('select2', '4.0.3', 'bds.theme:static/select2/select2-4.0.3.js')
    registry.set_css_resources('select2', '4.0.3', 'bds.theme:static/select2/select2-4.0.3.cs')

Form.set_default_resource_registry(registry) 

 I have also set up a static route but it doesn't seem to have any effect.

config.add_static_view(bds.theme:static,,bds.theme:static, cache_max_age=86400)
    
I no longer get the value error with this  setup but instead I get a 401 error if I try and look for the file referred to. 
It says the file is found at:

What am I missing in my setup? Do the js files have to be in the deform folders?

Jo G

unread,
Oct 20, 2016, 6:23:01 AM10/20/16
to pylons-discuss
I worked this out for myself. Deform will use external requirements where you have added a static view.  You just need to make sure that the name of the file is correct. (.css not cs!)
Reply all
Reply to author
Forward
0 new messages