Re: [pylons-devel] Newbie question: How to run task after the pyramid web app is up?

2014-01-28 Thread Daniel Holth
Here are the available events in Pyramid. http://docs.pylonsproject.org/projects/pyramid/en/latest/api/events.html#pyramid.events.ApplicationCreated On Tue, Jan 28, 2014 at 1:30 PM, Gael Pasgrimaud wrote: > On Tue, Jan 28, 2014 at 04:25:14AM -0800, Jeryn Mathew wrote: >> Hello all, >> >> I have

Re: AuthTktAuthenticationPolicy using MD5

2012-09-24 Thread Daniel Holth
https://github.com/plone/plone.session/blob/master/plone/session/tktauth.py Have you been able to use your patch with Apache's mod_auth_tkt? On Sunday, September 23, 2012 12:03:43 PM UTC-4, Domen Kožar wrote: > > Created pull request, changed the approach a bit: > https://github.com/Pylons/pyra

Re: AuthTktAuthenticationPolicy using MD5

2012-09-21 Thread Daniel Holth
On Fri, Sep 21, 2012 at 1:54 PM, Domen Kožar wrote: > For generating secrets it's important to discourage usage of random module, > but use something like: > > secret = ''.join('%02x' % ord(x) for x in os.urandom(128)) Great wordpress site! Secrets transmitted in the clear without mandatory S

Re: AuthTktAuthenticationPolicy using MD5

2012-09-17 Thread Daniel Holth
Clearly in that case you are on your own. On Sep 17, 2012 12:57 PM, "Michael Merickel" wrote: > In an effort to maintain compliance with the auth_tkt standard versus > flexibility I would've rather seen this just accept the strings "md5", > "sha256", etc rather than an arbitrary callable that may

Re: AuthTktAuthenticationPolicy using MD5

2012-09-17 Thread Daniel Holth
On Friday, September 14, 2012 6:06:15 PM UTC-4, Chris McDonough wrote: > > On 09/14/2012 03:37 PM, Florian R�chel wrote: > > Hi Domen, > > > > I would agree with you if it would really complicate things much, but I > > can't see why it would. All those cases are really simple to implement >

Re: AuthTktAuthenticationPolicy using MD5

2012-09-09 Thread Daniel Holth
I dislike md5 as much as the next guy, but auth_tkt uses a double hashing scheme that is almost hmac. Hmac overcomes most of the problems of an otherwise weak hash function. It isn't as bad as you might think. The sha2 functions are a great replacement. Sha2 auth_tkt is what I would use. Sha1 is d

Re: proposal to decouple colander from translationstring

2012-06-27 Thread Daniel Holth
translationstring installs these files, and it has no dependencies on Plone or any other package outside the standand library. cat translationstring-1.1-py2.7.egg-info/installed-files.txt ../translationstring/__init__.py ../translationstring/compat.py ../translationstring/tests/__init__.py ../tran

Re: Pyramid LDAP Authentication

2011-07-27 Thread Daniel Holth
IIRC repoze.who doesn't do anything without plugins. It should be safe to assume the ldap plugin will work fine with pyramid_who. It's usually simpler to do authentication in the pyramid application, not in middleware, but if you want to use repoze.who as a middleware then pyramid_who will reco

Re: Adding "abort" and "redirect" to Pyramid

2011-05-26 Thread Daniel Holth
'return' makes sense because views return a response. Whether the response has an error code of 200, 301 or 5xx is a separate concern. Of course exceptions make sense too. In Pyramid you could replace the standard context finding methods with a view that raises exceptions and build your whole a

Re: Documenting all HTTP requests to an application

2011-05-11 Thread Daniel Holth
You don't log requests already? Here is one: http://pythonpaste.org/modules/translogger.html Perhaps the format could just log the path without having to do any text processing on the file. I thought your original question was more like 'print out all the routes' without making requests to the ap

Re: pyramid view_config and redirect

2011-04-28 Thread Daniel Holth
The specific check is in view.py:is_response if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and hasattr(ob, 'status') ): return True return False -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to th

Re: GSoC, Python 3 dependencies, Paste

2011-04-05 Thread Daniel Holth
The web application format would be the equivalent of a .war file in the Java world, or whatever you have to provide for Google App Engine: a collection of your application code and static configuration that could be easily deployed on a compliant web server. For example you might be able to expres

Re: GSoC, Python 3 dependencies, Paste

2011-04-04 Thread Daniel Holth
IIRC Pyramid doesn't really depend on Paste in any important way. You could just try to get it working under CherryPy, uWSGI or wsgiref for example, and get the configuration dictionary some other way besides having Paste parse .ini into {}. I hope Ian's Web Application Format proposal gets spe

Re: requests and transaction (was Re: request lifecycle)

2011-03-31 Thread Daniel Holth
In other words you can probably get most of the same events by subclassing one of the deprecated classes. That SQLAlchemy has such low release numbers, and it's written by that scofflaw M. Bayer. Nobody should use it until 1.0, he should stick to directing Hollywood blockbusters. ;-) -- You r

Re: requests and transaction (was Re: request lifecycle)

2011-03-31 Thread Daniel Holth
SQLAlchemy 0.7 deprecates SessionExtension() and other abstract base classes and replaces them with an event interface. -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubs

Re: request lifecycle

2011-03-31 Thread Daniel Holth
transaction manager - calls -> repoze.bfg^Wpyramid -> your view Your view returns, pyramid pops the threadlocal context used by get_current_request, and then the transaction manager commits. You can't get the threadlocal request anymore because Pyramid has already done its cleanup and popped the

Re: WSGI and Async [was: Pyramid 2 ideas]

2011-03-25 Thread Daniel Holth
None of those points say anything about a perfect implementation of coroutines (I heard lua has the best ones) versus callback-style or some other more-stackful-style of asynchronicity. On the other hand for example I'm sure there is a lot of Twisted code that doesn't need to be rewritten. I ju

Re: WSGI and Async [was: Pyramid 2 ideas]

2011-03-24 Thread Daniel Holth
Proposal: import eventlet Done! Invented in 1963, coroutines let me use WSGI asynchronously without rewriting anything. What could be sweeter? -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@goo

Re: Terminology Change - Template to Skeleton

2011-03-21 Thread Daniel Holth
Joe, I enjoy posting to mailing lists but as far as I'm concerned you may change the name of things without asking in the future. I have already read the docs and would probably never notice. Daniel -- You received this message because you are subscribed to the Google Groups "pylons-devel" g

Re: Terminology Change - Template to Skeleton

2011-03-21 Thread Daniel Holth
When the almost-exactly-the-same-but-irritatingly-slightly-different version of paster has templates, sure. When paster create --list-templates is the only way to show the available scaffolding, no way! Real people can understand adjectives and compound terms. Also, 'template' and 'paster templ

Re: What's the best way to optimize database connections in Pyramid?

2011-03-16 Thread Daniel Holth
The normal strategy for databases is to use a connection pool. Conceptually the code gets a new connection each request but the pool may return an existing connection instead. Depending on the database this can be a big win; some databases connect so quickly that it hardly makes a difference. -

Re: Invoking views

2011-03-15 Thread Daniel Holth
Pyramid will normally only call one view per request. Is there a reason you cannot simply call view2 from view1? def view1(request): x = view2(request) ... -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send em

Re: Pyramid 2 ideas

2011-03-14 Thread Daniel Holth
IMO the only thing we need for configuration is a 100% compatible, no extra features version of Paster that is easier to read and extend, and that runs on Python 3.2. Call it 'baster'. It will understand Paster entry points, paste deploy .ini files and be able to 'baster serve'. The templating feat

Re: What's the best way to optimize database connections in Pyramid?

2011-03-13 Thread Daniel Holth
In this case it only means "replace the function with its return value as a kind of cache" -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send

Re: WebOb 1.0.2 + request.copy() + os.fork() + hang

2011-03-13 Thread Daniel Holth
p at http://groups.google.com/group/pylons-devel?hl=en. """ Test forking and Request.copy(). This test should be skipped on Windows. Daniel Holth """ from multiprocessing import Process from webob import Request, Response from wsgiref.simple_server import make_server impor

WebOb 1.0.2 + request.copy() + os.fork() + hang

2011-03-12 Thread Daniel Holth
I have been having trouble with request.copy() and ReloadWSGI with WebOb >= 1.0.2. In WebOb 1.0.2 and greater request.copy() hangs. static_url() uses request.copy() so my Pyramid application hangs as soon as it tries to serve some css. In WebOb 1.0.4 from pypi, it hangs at request.py:673 which

Re: Some thoughts about Pyramid

2011-03-04 Thread Daniel Holth
My wishlist for the manual: 1. searching for request.response_headers should pull up request.response_headerlist 2. glossary for 'Configurator' etc. should link to function signatures -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to t

Re: Some thoughts about Pyramid

2011-03-04 Thread Daniel Holth
Pasta is delicious. Choice is here to stay. I think frustrated people tend to overestimate the cost of reading a 600-page book (the documentation) or installing 17 dependencies (automatically). It will pay off to understand the tools you are using over the lifetime of a significant application;

Re: Some thoughts about Pyramid

2011-03-04 Thread Daniel Holth
Psychologists have done a significant amount of research documenting the "tyranny of choice" and famously served samples of exotic jams "when choice is demotivating" ( http://www.columbia.edu/~ss957/articles/Choice_is_Demotivating.pdf). At least for jam, 6 choices is OK, while 30 choices are demoti

Re: webhelpers.paginate: html entity for symbol_previous|next

2011-03-01 Thread Daniel Holth
Wrap « in webhelpers.html.literal() or ...set # -*- coding: utf-8 -*- in your Python file and just pass the unicode character to the batcher. -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@goog

Re: pyramid_beaker vs beaker wsgi middleware

2011-02-28 Thread Daniel Holth
Clearly it will take time for individuals to understand which functionality best belongs in each layer. REMOTE_USER makes great middleware but it's trivial to move that bit, or sessions, into or out of Pyramid as desired. -- You received this message because you are subscribed to the Google Gro

Re: authenticated_userid vs unauthenticated_userid

2011-02-28 Thread Daniel Holth
I think the reasoning is that "Interpret the current user id from a cookie / kerberos authentication / some key in the session" and "see whether the identified user exists in our system" should be in different layers. I agree this leaves me scratching my head as to when the distinction is usefu

Re: pyramid_beaker vs beaker wsgi middleware

2011-02-28 Thread Daniel Holth
On Sun, Feb 27, 2011 at 2:15 PM, oO wrote: > Sorry if this is a basic question, but as I'm starting to add more and > more layers of complexity to my first pyramid based applications, I'm > starting to wonder about some of the benefits of using pyramid > specific implementations as opposed to re-

Re: default permission overriding

2011-02-22 Thread Daniel Holth
There is a constant. It is called pyramid.interfaces.NO_PERMISSION_REQUIRED ; however, the string is documented. This probably makes the documentation shorter because you would have to use the string if you are configuring with ZCML. This is /only/ required at all when you need your application to

Re: "user objects"

2011-02-22 Thread Daniel Holth
If you do it properly, you can .get(primary_key) the user from the SQLAlchemy session and it only hits the storage once per transaction. If the object hasn't been garbage collected, subsequent .get() calls will hit the identity map, which can be used as a kind of cache but which is really there

Re: Deform readonly fields

2011-02-22 Thread Daniel Holth
I did something like this too. I need to be able to show readonly fields in my forms in the same way I do in formish, so I implemented a per-field readonly flag. It works okay but it is a little cumbersome to specify which fields are readonly: deform/field.py: def serialize(self, cstruct, re

Re: docs unclear re using zope global registry

2011-02-18 Thread Daniel Holth
I think you are correct. -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more optio

Re: docs unclear re using zope global registry

2011-02-18 Thread Daniel Holth
If you want to use the global ZCA then you should call Configurator.hook_zca. See http://docs.pylonsproject.org/projects/pyramid/dev/api/config.html#pyramid.config.Configurator.hook_zca Global ZCA means calls to zope.component.getUtility(ISomething) instead of request.registry.getUtility(ISomet

Re: Beaker caching in a view callable defined as a class in Pyramid

2011-02-04 Thread Daniel Holth
cache_key = " ".join(map(str, deco_args + args)) One way is to define a __str__ method for your class that doesn't include the object's id() -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@goog

Re: Using SQLAlchemy with Traversal.

2011-01-25 Thread Daniel Holth
Kyle, You should be able to do something as simple as class Foo: bars = relationship(Bar, backref='__parent__') Is it necessary? With the default traversal implementation you override __getitem__ to return objects with __name__ and __parent__: def __getitem__(self, key): b

Re: How to mock models while testing views?

2011-01-25 Thread Daniel Holth
Typically my models are not very smart, so I am not usually worried about model-bugs interfering with other tests and I just insert real ones into a sqlite:///:memory: database. However, def view_under_test(request): return dict(user_id=request.db.query(User).get(authenticated_userid(reques

Re: Form handling in Pyramid

2011-01-21 Thread Daniel Holth
I think it is very relaxing that my view handles unedited requests. I'm confused about the problem you are having. Since the framework keeps GET requests out, why does the PUT-handler have to check request.method at all? -- You received this message because you are subscribed to the Google Grou

Re: Form handling in Pyramid

2011-01-21 Thread Daniel Holth
I always setup two view functions, one for GET and one for POST. I don't do PUT, but if you want Pyramid lets you condition a view on both the request method and parameters. The second function should only be called for a PUT, or a POST with _method=PUT in the parameters: def some_method(reques

Re: stucco_auth 0.1e-6 released

2011-01-21 Thread Daniel Holth
its dependencies. Thanks, Daniel Holth -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@google

Re: stucco_auth 0.1e-6 released

2011-01-21 Thread Daniel Holth
r to understand and test, and there is no need to agree on a common module to hold those globals. Daniel Holth -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com.

stucco_auth 0.1e-6 released

2011-01-20 Thread Daniel Holth
that needs logins. I hope someone will find it useful. Let me know if you give it a try. http://pypi.python.org/stucco_auth https://bitbucket.org/dholth/stucco_auth Thanks Rocky for your contributions. Daniel Holth -- You received this message because you are subscribed to the Google Groups &q

Re: [pyramid_jinja2] I would like to have access to "settings" in my custom IJinja2Environment utility

2011-01-07 Thread Daniel Holth
In that case, in the function that creates your application: c = Configurator(settings) e = Environment(auto_reload=asbool(settings['auto_reload'])) c.registry.registerUtility(e, IJinja2Environment) -- You received this message because you are subscribed to the Google Groups "pylons-devel" grou

Re: [pyramid_jinja2] I would like to have access to "settings" in my custom IJinja2Environment utility

2011-01-06 Thread Daniel Holth
Stephane, {{ request.registry.settings }} -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.c

stucco_evolution design

2010-12-22 Thread Daniel Holth
I am interested in supporting multiple packages that depend on each other's tables as a directed acyclic graph and do not import a common declarative base. To support that goal I've been working on stucco_evolution. stucco_evolution is an extension of repoze.evolution that works with SQLAlchemy

Re: How can I build a restful service using pyramid?

2010-12-22 Thread Daniel Holth
Look at the view_attr and request_method parameters to add_route. If you have a naming convention for your classy views it should be extremely easy to do something like (untested): class ViewClass(object): def __init__(self, request): self.request = request def GET(self):

Re: pyramid terminology: "model"->"resource"

2010-12-17 Thread Daniel Holth
+1 'resource' is awesome. I retract all my previous objections. Thanks wordsmiths Mark and Chris. -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group,

Re: pyramid terminology: "model"->"resource"

2010-12-15 Thread Daniel Holth
-1 I think the word 'resource' is at least as overloaded as the word 'model'. If it's a graph it could contain nodes? After an "aha" moment, I always thought of my bfg app as having a traversal model /and/ a data model, with the leaves of the traversal model tending to be SQLAlchemy mapped cla

Re: Using beaker cache with pyramid

2010-12-12 Thread Daniel Holth
Pyramid calls a view with the request if it accepts one positional argument, but the cache decorator hides the function's signature so Pyramid passes the context and the request. If you change your view to def home_view(context, request): pass It will probably do something. However, str(context)

Re: Using beaker cache with pyramid

2010-12-11 Thread Daniel Holth
Massimiliano, I went down the same path of looking for a per-request caching middleware that worked in the same way as the session middleware. Eventually I decided caching was not tied to a single request in the same way as a session, so I have a global cache as Wichert suggests. Daniel -- You

Re: URL dispatch vs traversal

2010-12-06 Thread Daniel Holth
I don't know what all you guys are smoking with this half-cocked "routes" system. Personally it makes no sense to me. I started developing web pages by putting index.html in a folder, and if I visited that folder I would see index.html. Now I put an object in a nested dict, the framework finds it,

Global SQLAlchemy Session

2010-11-29 Thread Daniel Holth
ommon enough to be a default feature. I've been using repoze.bfg for a little more than a year. I have a few repoze.bfg and now Pyramid applications that use SQLAlchemy but I have not finished figuring out how to factor out the common parts. Daniel Holth -- You received this message becau

Re: Pyramid project templates

2010-11-24 Thread Daniel Holth
On the other hand, when I configure my engine from the .ini it's just configure_engine(settings['sqlalchemy.url']) So I think the way it works now is fine. Daniel Holth -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To

Re: Pyramid project templates

2010-11-24 Thread Daniel Holth
.html#sqlalchemy.orm.scoping.ScopedSession.query_property However, a class could be written as: from sqlalchemy.orm.util import object_session ... def do_something_with_session(self): object_session(self).query()... - Daniel Holth -- You received this message because you are subscribed to the Google Groups "pylons-devel&

Re: permissions with handlers

2010-11-20 Thread Daniel Holth
PYRAMID_DEBUG_AUTHORIZATION=1 chris?) Daniel Holth -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com