Re: pylons with chameleon?
On 2009-9-24 07:53, Iain Duncan wrote: In Sat, 2009-09-19 at 09:40 +0200, Wichert Akkerman wrote: On 2009-9-16 21:06, Iain Duncan wrote: Hi folks, I have not built enough pylons to be know how to switch templating languages beyond mako and genshi, but I'm interested in using Chameleon. Has anyone got any examples up of what one needs to do to use Chameleon? Thanks Wichert, I've hit some problems here, and muddled along a bit, if you ( or someone ) can check this that would be great. In config/environment.py: from genshi.template import TemplateLoader as GenshiTemplateLoader Doh, that line should have read: from chameleon.genshi.loader import TemplateLoader I assume I'm also supposed to add?? from chameleon.zpt.loader import TemplateLoader That depends. Personally I use chameleon.genshi since I prefer Genshi syntax over zpt. If you want to use the Zope page template syntax you'll want to replace chameleon.zpt. def load_environment(global_conf, app_conf): ... ... # Create the chameleon TemplateLoader config['pylons.app_globals'].pt_loader = TemplateLoader( paths['templates'], auto_reload=True) Add a new file in lib (mine is called lib/pt.py): from pylons.templating import pylons_globals from pylons.templating import cached_template def render_pt(template_name, cache_key=None, cache_type=None, cache_expire=None): Render a page template with z3c.pt. def render_template(): globs = pylons_globals() template = globs[app_globals].pt_loader.load(template_name) return template(**globs) return cached_template(template_name, render_template, cache_key=cache_key, cache_type=cache_type, cache_expire=cache_expire) def render_text(template_name, cache_key=None, cache_type=None, cache_expire=None): Render a text template with z3c.pt. def render_template(): globs = pylons_globals() template = globs[app_globals].pt_loader.load(template_name, format=text) return template(**globs) return cached_template(template_name, render_template, cache_key=cache_key, cache_type=cache_type, cache_expire=cache_expire) you can then use render_pt to render html/xml templates, and render_text to render text templates, exactly like you use other templating languages. I copied the above in, and imported render_pt from lib/pt.py, but when I try to render a template like so: (in a controller) def zpt(self): test of using zpt templates return render_pt(mytemplate.pt) I get the following traceback, any help much appreciated. File '/home/ymh/pylons_full/pylons_full/controllers/peek.py', line 50 in zpt File '/home/ymh/pylons_full/pylons_full/lib/pt.py', line 15 in render_pt cache_key=cache_key, cache_type=cache_type, cache_expire=cache_expire) File '/home/ymh/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/templating.py', line 249 in cached_template return render_func() File '/home/ymh/pylons_full/pylons_full/lib/pt.py', line 11 in render_template template = globs[app_globals].pt_loader.load(template_name) File '/home/ymh/lib/python2.5/site-packages/chameleon.zpt-1.0.0-py2.5.egg/chameleon/zpt/loader.py', line 11 in load template.PageTemplateFile) File '/home/ymh/lib/python2.5/site-packages/chameleon.core-1.0.0-py2.5.egg/chameleon/core/loader.py', line 8 in load self.registry[args] = template = func(self, *args) File '/home/ymh/lib/python2.5/site-packages/chameleon.core-1.0.0-py2.5.egg/chameleon/core/loader.py', line 39 in load path, self.parser, auto_reload=self.auto_reload) TypeError: __init__() takes exactly 2 non-keyword arguments (3 given) Hm, the chameleon.zpt template has not seen as much love as the chameleon.genshi version so it might have broken somewhere. Can you test if chameleon.genshi works for you? If so I'll look at fixing up the chameleon.zpt version. Wichert. -- Wichert Akkerman wich...@wiggy.net It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: pylons with chameleon?
Mike, I think they may be talk about this http://chameleon.repoze.org/ Regards, KMCB On Sep 24, 9:41 am, Mike Orr sluggos...@gmail.com wrote: On Wed, Sep 16, 2009 at 12:06 PM, Iain Duncan iaindun...@telus.net wrote: Hi folks, I have not built enough pylons to be know how to switch templating languages beyond mako and genshi, but I'm interested in using Chameleon. Has anyone got any examples up of what one needs to do to use Chameleon? What is Chameleon anyway? I googled and found thishttp://www.interfaceware.com/manual/chameleon.html Welcome to Chameleon, an intuitive and easy-to-use software tool for adding industry-standard message capabilities to new or existing healthcare applications. Is this the Chameleon you're talking about? -- Mike Orr sluggos...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: pylons with chameleon?
On Thu, Sep 24, 2009 at 9:03 AM, KMCB kmcbrea...@yahoo.com wrote: Mike, I think they may be talk about this http://chameleon.repoze.org/ So it's a template engine unifier, the way Buffet was and render_* are. It also claims to be faster than the native engines ported to it? -- Mike Orr sluggos...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: jsonify validator
On Sep 24, 10:09 am, Jonathan Vanasco jonat...@findmeon.com wrote: Jsonify is only ten lines or so. You can copy it and add this feature. It's too specific for Pylons though. (What would the config variable be, 'jsonify_content_type'?) I disagree that its too specific. It's a change that would make it easier for developers to test jsonify content in their browser, without having to use firefox with a special plugin -- which is what people currently have to do. I think making things easier for a general audience of Pylons developers to code test is good. I don't need this personally. I use a library function to create structured dicts that are turned into JSON , and put this functionality in there. But I do think it is of benefit to others. And yes, I was thinking of a change like this : - pylons.response.headers['Content-Type'] = 'application/json' + if 'pylons.jsonify_content_type' in pylons.config: + pylons.response.headers['Content-Type'] = pylons.config ['pylons.jsonify_content_type'] + else: + pylons.response.headers['Content-Type'] = 'application/json' I'm -0 on this idea, but if it goes in, I'd prefer this implementation: -pylons.response.headers['Content-Type'] = 'application/json' + pylons.response.content_type = config.get('json_content_type', 'application/json') I don't think the JSONView Firefox add-on qualifies as particularly special, and the formatting colorization is very nice. When I've viewed JSON as text in the browser, it's been nearly unreadable because it was all squished together didn't wrap. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: jsonify validator
On Sep 24, 12:04 pm, Mike Orr sluggos...@gmail.com wrote: On Thu, Sep 24, 2009 at 11:38 AM, Wyatt Baldwin wyatt.lee.bald...@gmail.com wrote: On Sep 24, 10:09 am, Jonathan Vanasco jonat...@findmeon.com wrote: Jsonify is only ten lines or so. You can copy it and add this feature. It's too specific for Pylons though. (What would the config variable be, 'jsonify_content_type'?) I disagree that its too specific. It's a change that would make it easier for developers to test jsonify content in their browser, without having to use firefox with a special plugin -- which is what people currently have to do. I think making things easier for a general audience of Pylons developers to code test is good. I don't need this personally. I use a library function to create structured dicts that are turned into JSON , and put this functionality in there. But I do think it is of benefit to others. And yes, I was thinking of a change like this : - pylons.response.headers['Content-Type'] = 'application/json' + if 'pylons.jsonify_content_type' in pylons.config: + pylons.response.headers['Content-Type'] = pylons.config ['pylons.jsonify_content_type'] + else: + pylons.response.headers['Content-Type'] = 'application/json' I'm -0 on this idea, but if it goes in, I'd prefer this implementation: - pylons.response.headers['Content-Type'] = 'application/json' + pylons.response.content_type = config.get('json_content_type', 'application/json') I don't think the JSONView Firefox add-on qualifies as particularly special, and the formatting colorization is very nice. When I've viewed JSON as text in the browser, it's been nearly unreadable because it was all squished together didn't wrap. response.content_type is translated to response.headers['content-type'] so they're the same (except that I forget the property exist). Yes, it was a bikeshed-esque comment on my part. ;) I don't see how either way addresses wrapping, although I think simplejson has an argument to pretty-format which we could enable. With pretty formatting, I'd be more like +0 on this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Beaker error
On Mar 2, 2009, at 11:24 AM, Mike Orr wrote: I've started getting an intermittent Beaker error. It happens in the base controller when I pass ``session.id`` to a generic logging routine. However, I have three sites with the same logging code, and it's only happening on one of the sites. It occurs on a variety of URLs. Here's the exception: Module beaker.synchronization:260 in do_acquire_write_lock return False else: fcntl.flock(filedescriptor, fcntl.LOCK_EX) return True fcntl.flock(filedescriptor, fcntl.LOCK_EX) TypeError: argument must be an int, or have a fileno() method. FYI I narrowed this problem down today, it should be fixed in Beaker trunk. It's due to a CPython bug =[ http://www.pylonshq.com/project/pylonshq/ticket/645 -- Philip Jenvey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Py Web SF #4: 6pm, Tues September 29th, SF Main Public Library
Hi folks, PyWebSF is a Python meet-up with a strong focus on Web technology. From frameworks like WSGI/Pylons/TurboGears/Django to libraries like httplib2 to using emerging Web technologies like Amazon's AWS and Freebase - its all covered. The emphasis is on practical, hands-on lectures and discussion. Meetings start with one or two 30-40 minute presentations and end with informal discussion. Hackathon-style collaboration and project demos are encouraged. Who/What * Jamie Taylor - Borrowing from the Semantic Web to make your data more flexible http://www.pywebsf.org/2009/09/23/jamie-taylor-borrowing-from-the-semantic-web-to-make-your-data-more-flexible/ * Harry Tormey - Working with Facebook and Pylons http://www.pywebsf.org/2009/09/23/harry-tormey-working-with-facebook-and-pylons/ When 6PM, Tuesday 29 September 2009. Please try to arrive on time to avoid disappointment. We have space for around 10-20 people. Where - Stong conference room, 1st floor, SF Main Public Library. Map: http://tinyurl.com/pywebsfmap The library is easily accessible via both BART and Muni at the Civic Center station. The library closes at 8pm so we will continue the discussion over food/drinks at Frjtz Fries [http://www.frjtzfries.com]. More info - Subscribe to our Google Calendar at http://tinyurl.com/pywebcal Slides, links, and more at http://pywebsf.org/ Thanks! -- Niall O'Higgins PyWebSF http://pywebsf.org http://niallohiggins.com @niallohiggins on Twitter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---