chameleon

Chameleon templates for javascript files?

此生再无相见时 提交于 2019-12-18 05:05:37
问题 I am developing a simple pyramid application where I am using JQuery to do AJAX requests. I have until now had my javascript code within my chameleon templates. Now I want to extract my javascript into another location (e.g. as static resources). My problem is that I find my javascript code relies on dynamically generated content like so: $.post("${request.route_url('my_view')}",{'data': 'some data'}, function(html){ $("#destination").html(html); }); The dynamic element being: "${request

dynamicly fill table using zpt and ajax as update

谁说我不能喝 提交于 2019-12-13 19:17:12
问题 I'm creating a webproject in pyramid where I'd like to update a table every few secondes. I already decided to use ajax, but I'm stuck on something. On the client side I'm using the following code: function update() { var variable = 'variable '; $.ajax({ type: "POST", url: "/diagnose_voorstel_get_data/${DosierID}", dataType: "text", data: variable , success: function (msg) { alert(JSON.stringify(msg)); }, error: function(){ alert(msg + 'error'); } }); } Pyramid side: @view_config(route_name=

using base layout templates in chameleon

怎甘沉沦 提交于 2019-12-12 13:16:40
问题 In the pyramid docs there is a nice tutorial on UX stuff here: http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/humans/creatingux/step07/index.html One thing I noticed though is in the tutorial they are setting up and passing around the 'global layout' explicitly in the code (see below). I thought this was unusual and unnecessary because I've always just used the 'load' command as shown in the docs here: http://chameleon.repoze.org/docs/latest/ Is this just a personal

tal nested dictionary syntax

。_饼干妹妹 提交于 2019-12-11 08:30:35
问题 Working with Pyramid, my code looks like this: class PageData: @staticmethod def create_data(): return [ { 'key_1A': 'info1A', 'key_2A': 'info2A', 'nested_list_A': [ {'nested_key1A': 'nested_val1A'}, {'nested_key2A': 'nested_val2A'}, ], }, { 'key_1A': 'info1B', 'key_2A': 'info2B', 'nested_list_B': [ {'nested_key1B': 'nested_val1B'}, {'nested_key2A': 'nested_val2A'}, ], }, ] And my html page code looks like this: <span tal:condition="nested_key1A"> Open </span> <span tal:condition="not nested

Trouble repeating elements using TAL, Chameleon and Pyramid

流过昼夜 提交于 2019-12-08 03:27:50
问题 I'm really struggling to get TAL and Chameleon/Pyramid to play nice. . . I have a view in Pyramid that returns, for example, the following: def view(request): return {'results' : [ {'name':'alice', 'value':22}, {'name':'bob', 'value':11}, {'name':'charlie', 'value':33} ] } I have a template that contains the following bit of HTML: <!DOCTYPE html> <html> <head></head> <body> <table> <thead> <tr> <td>Keyword</td> <td class="center">Mean Position</td> </tr> </thead> <tbody> <tr tal:repeat"row

Trouble repeating elements using TAL, Chameleon and Pyramid

时光毁灭记忆、已成空白 提交于 2019-12-07 22:42:25
I'm really struggling to get TAL and Chameleon/Pyramid to play nice. . . I have a view in Pyramid that returns, for example, the following: def view(request): return {'results' : [ {'name':'alice', 'value':22}, {'name':'bob', 'value':11}, {'name':'charlie', 'value':33} ] } I have a template that contains the following bit of HTML: <!DOCTYPE html> <html> <head></head> <body> <table> <thead> <tr> <td>Keyword</td> <td class="center">Mean Position</td> </tr> </thead> <tbody> <tr tal:repeat"row results"> <td>${row.name}</td> <td>${row.value}</td> </tr> </tbody> </table> </body> </html> I'm hoping

ajax widgets in pyramid and chameleon

可紊 提交于 2019-12-04 15:12:29
问题 I would like to be able to easily create ajax 'widgets' backed by chameleon and pyramid on the server side. Does Pyramid provide any plumbing code that would make writing widgets easy? My current approach is I have a home view which uses home.pt as the renderer. home.pt uses a macro base.pt which defines the page structure and provides a slot for home.pt to fill. base.pt also uses a login 'widget' macro that I have written (see: account_login_widget.pt below). In theory, this all sounds great

Dependent/Cascading inputs using Deform

烈酒焚心 提交于 2019-12-02 03:49:16
问题 I'm trying to do a series of dependent inputs with Deform / Colander / Chameleon / Pyramid and can't find any examples. e.g. Dropdown of Country yields-> Dropdown of State or Province or Division ..etc.. yields-> Dropdown of County or City ... might yield-> Dropdown of City ... Can this be accomplished using Deform? (if it can't, should I look at an alternative form generating solution or go pure html/javascript/ajax/..?) I'm simplifying this to geographic divisions. I'd prefer to send only

Dependent/Cascading inputs using Deform

断了今生、忘了曾经 提交于 2019-12-01 23:35:01
I'm trying to do a series of dependent inputs with Deform / Colander / Chameleon / Pyramid and can't find any examples. e.g. Dropdown of Country yields-> Dropdown of State or Province or Division ..etc.. yields-> Dropdown of County or City ... might yield-> Dropdown of City ... Can this be accomplished using Deform? (if it can't, should I look at an alternative form generating solution or go pure html/javascript/ajax/..?) I'm simplifying this to geographic divisions. I'd prefer to send only the necessary part of the 12 million record database at the time the form is loaded and incrementally

Python Pyramid & Chameleon templating language escapes html

☆樱花仙子☆ 提交于 2019-12-01 08:03:37
I can't make sense of chameleon's tags. I'm a django user, but decided to introduce my CompSci course mates and myself to Pyramid, since I though more lightweight = easier to learn. At the moment the ${} tag is escaping any html tags I'm trying to output through it. In django there was some way to specify that a variable is "safe" and doesn't need to be escaped. How can I do the same thing in Pyramid / Chameleon? Chameleon is based on the Zope Page Templates library, so if you find the Chameleon documentation lacking, you might wish to check out the zpt docs. In any case, there are two main