[pylons-discuss] Distinguish between pserve and pshell in main

2015-07-29 Thread Martin Stein
Hi all, is there an elegant way in the central main(..)-function to determine if the application was started from pserve or pshell? I'm launching a background thread from there, which does some regular polling of a 3rd-party API. Obviously I don't want to start that thread when the

[pylons-discuss] Re: Distinguish between pserve and pshell in main

2015-07-29 Thread Martin Stein
Gael Pasgrimaud: On Wednesday, July 29, 2015 at 2:06:29 PM UTC+2, Martin Stein wrote: Hi all, is there an elegant way in the central main(..)-function to determine if the application was started from pserve or pshell? Don't know if it's elegant but sys.argv[0].endswith('pshell

[pylons-discuss] Re: Hook for serialization to JSON with marshmallow schemas

2015-07-20 Thread Martin Stein
post can be found here: https://github.com/martinstein/json-example Hope that might be helpful to some people. Regards, Martin Am Montag, 8. Juni 2015 17:04:46 UTC+2 schrieb Jonathan Vanasco: On Monday, June 8, 2015 at 5:23:03 AM UTC-4, Martin Stein wrote: @Jonathan: Probably you know

Re: [pylons-discuss] Re: Render Jinja-template to string

2015-07-09 Thread Martin Stein
master): https://github.com/martinstein/pyramid_jinja_issue Am Mittwoch, 8. Juli 2015 13:17:53 UTC+2 schrieb Martin Stein: Yes, renderer='email/mytemplate.html' is exactly the one that doesn't work. So this is the one that's either a bug in pyramid_jinja2 or I'm simply missing how

Re: [pylons-discuss] Re: Render Jinja-template to string

2015-07-08 Thread Martin Stein
Yes, renderer='email/mytemplate.html' is exactly the one that doesn't work. So this is the one that's either a bug in pyramid_jinja2 or I'm simply missing how to specify the path to the subdirectory. Am Mittwoch, 8. Juli 2015 02:22:30 UTC+2 schrieb Jonathan Vanasco: Have you tried:

[pylons-discuss] Re: Render Jinja-template to string

2015-07-07 Thread Martin Stein
, 7. Juli 2015 20:10:39 UTC+2 schrieb Martin Stein: Hi all, in our current project we are using jinja with the pyramid_jinja2-package and have defined the search-path in __init__.py as usual: config.add_jinja2_search_path('proj:templates', name='.html') Now I need to use that renderer

[pylons-discuss] Render Jinja-template to string

2015-07-07 Thread Martin Stein
Hi all, in our current project we are using jinja with the pyramid_jinja2-package and have defined the search-path in __init__.py as usual: config.add_jinja2_search_path('proj:templates', name='.html') Now I need to use that renderer/jinja-environment to render a file-template to a string

Re: [pylons-discuss] Re: Render Jinja-template to string

2015-07-07 Thread Martin Stein
a reproducible example to an issue I'd be happy to take a look. On Tue, Jul 7, 2015 at 2:18 PM, Martin Stein mstei...@gmail.com javascript: wrote: Hi everybody, sorry, my last email was premature. I've gotten it to work like this: from pyramid.renderers import render render

[pylons-discuss] Re: Hook for serialization to JSON with marshmallow schemas

2015-06-08 Thread Martin Stein
@Jonathan: Probably you know this already, but have you seen the 'add_adapter' method for extending the pyramid JSON renderer? One of the first things I do when I start a new Pyramid-project is to add an adapter for datetime. Am Sonntag, 7. Juni 2015 17:21:17 UTC+2 schrieb Jonathan Vanasco:

[pylons-discuss] Hook for serialization to JSON with marshmallow schemas

2015-06-06 Thread Martin Stein
Hi all, in my current project we use SQLAlchemy, so we need to be able to render SQLAlchemy-instances to JSON. We cannot simply provide a __json__-method, because the serialization depends on the context. Sometimes, you want to serialize the object without any relations (e.g. only the

[pylons-discuss] Re: Hook for serialization to JSON with marshmallow schemas

2015-06-06 Thread Martin Stein
@Gael: Interesting idea, I hadn't thought about that. Though the no-arguments aspect might be a bit of a problem. The approach of attaching the schema to the request in the view-function: request.marshmallow_schema = UserOutputSchema() ... has another advantage besides allowing arguments: You

[pylons-discuss] Re: Hook for serialization to JSON with marshmallow schemas

2015-06-06 Thread Martin Stein
Good point. I guess that would work for 1 domain object: users. But the whole approach for modifying the JSON-serialization should work for multiple view-methods with different model-classes. E.g.: def get_own_user(request): ... def get_posts(request): ... def

[pylons-discuss] Inheritance for class-based views

2014-04-27 Thread Martin Stein
Hi all, Lately I've worked on a REST API where I tried to use class-based views that inherit from a base view class. I struggled a bit until I got the approach working, so I thought I'd write up the solution in case anyone else wonders about this. It is somewhat inspired by Cornice but I

Different static directories for development/production

2012-01-16 Thread Martin Stein
Hi everyone, For the current project at work, we are looking into using require.js (http://requirejs.org/) to combine, modularize and minify our javascript. So, basically, we need to have a server-side build step before serving our static files. Our plan is as follows: - have our pre-build

Re: Different static directories for development/production

2012-01-16 Thread Martin Stein
[2]http://pypi.python.org/pypi/pyramid_fanstatic [3]http://www.gawel.org/weblog/en/2011/12/Using_lesscss_with_pyramid_and... On Mon, Jan 16, 2012 at 3:08 PM, Marius Gedminas mar...@gedmin.as wrote: On Mon, Jan 16, 2012 at 05:28:45AM -0800, Martin Stein wrote: For the current project

Re: Different static directories for development/production

2012-01-16 Thread Martin Stein
:28:45AM -0800, Martin Stein wrote: For the current project at work, we are looking into using require.js (http://requirejs.org/) to combine, modularize and minify our javascript. So, basically, we need to have a server-side build step before serving our static files. Our plan

Re: Different static directories for development/production

2012-01-16 Thread Martin Stein
Chris, thanks, an approach like that was exactly what I was looking for! @Jonathan: Your suggestion sounds interesting, though I'm not sure I understand everything. Why are javascript templates (we are talking about things like Mustache or Handlebar templates, right?) a special case? They are

Difference between the new markupsafe and webhelpers.html escape

2010-07-14 Thread Martin Stein
Hi all, I've noticed that the pylons trunk template defaults to using the escape function from markupsafe now (previously from webhelpers.html) I think the move to markupsafe is great (fast c-extension), but the two filters escape None differently: import webhelpers.html, markupsafe

Re: Extracting Django forms from Django

2010-04-20 Thread Martin Stein
For me, the main reasons why I like Django's forms are: a) html widgets (without having to maintain my own mako form widgets library, as in Mike's approach) b) I mostly understand the source code c) well documented Also, I've never really felt comfortable with formencode. I can't really explain

Extracting Django forms from Django

2010-04-19 Thread Martin Stein
Hi all, Recently, I've begun trying to extract Django's forms from Django itself. I'd like to create a library that is usable in Pylons (and elsewhere) without importing the rest of Django. Can someone give me a hint on how to solve the i18n part? I have to rip out Django's own translation

Re: Extracting Django forms from Django

2010-04-19 Thread Martin Stein
Thanks for the hint. I've already read about Marcus' way of using Django forms (which is really nice), but his method means that you have the complete Django project as a dependency. I think some people might like a more light-weight approach. That's why I'm trying to extract the forms part only.

paster shell and new ipython0.10 problem

2009-08-13 Thread Martin Stein
Hi all, On August 6th a new version of ipython (0.10) was released. When I use paster shell with that version, I get a strange error: In [1]: for i in range(4): ERROR: 'dict' object has no attribute 'len' It seems that for-iteration over lists is broken. In normal ipython (without paster shell)