Strange beaker 1.1 error

2008-12-15 Thread alecf

We are unfortunately still on Python 2.4, but we have brought hashlib
in (from http://pypi.python.org/pypi/hashlib ) because we needed it
elsewhere in our project.

We are seeing some strange exceptions when using paste.httpexceptions
- I'm theorizing that beaker's hashlib / sha1 / md5 usage is confused
because we're at python 2.4 + hashlib, or something. Anybody have
ideas here? maybe the hashlib from pypi is not QUITE compatible with
the python 2.5 hashlib? is this a Beaker bug?

(sorry stack is slightly mangled, but hopefully readable)

AttributeError: 'builtin_function_or_method' object has no attribute
'new'hex:~/ly/build/_work/client-trunk_2008.12.15-18.44.58/_install%...
%g'/app08-hour
File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/
httpexceptions.py', line 249 in response
  headers, content = self.prepare_content(environ)
File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/
httpexceptions.py', line 233 in prepare_content
  content = self.html(environ)
File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/
httpexceptions.py', line 218 in html
  body = self.make_body(environ, self.template, html_quote, no_quote)
File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/
httpexceptions.py', line 205 in make_body
  args[k] = escfunc(v)
File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/util/
quoting.py', line 36 in html_quote
  return cgi.escape(unicode(v).encode(encoding), 1)
File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/
session.py', line 481 in __repr__
  return self._session().__repr__()
File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/
session.py', line 458 in _session
  self.__dict__['_sess'] = Session(req, use_cookies=True,
File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/
session.py', line 86 in __init__
  self.cookie = SignedCookie(secret, input=cookieheader)
File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/
session.py', line 36 in __init__
  Cookie.BaseCookie.__init__(self, input)
File '/usr/lib64/python2.4/Cookie.py', line 568 in __init__
  if input: self.load(input)
File '/usr/lib64/python2.4/Cookie.py', line 621 in load
  self.__ParseString(rawdata)
File '/usr/lib64/python2.4/Cookie.py', line 651 in __ParseString
  rval, cval = self.value_decode(V)
File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/
session.py', line 40 in value_decode
  sig = hmac.new(self.secret, val[40:], sha1).hexdigest()
File '/usr/lib64/python2.4/hmac.py', line 107 in new
  return HMAC(key, msg, digestmod)
File '/usr/lib64/python2.4/hmac.py', line 42 in __init__
  self.outer = digestmod.new()
AttributeError: 'builtin_function_or_method' object has no attribute
'new'

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting the content type in Pylons 0.9.6

2007-09-26 Thread alecf

I'm trying to render some Atom feeds with Pylons -
I've got a genshi template that more or less renders the atom feed,
but I need to return it as application/atom+xml

For the life of me I can't figure out how the new global response
object works - setting content_type has no effect.. my controller
looks something like:

response.content_type = application/atom+xml
response.content = render(genshi-xml, atom-feed)

(I had to write my own 'genshi-xml' engine plugin wrapper for Genshi,
because Genshi's default requires the file extension to be .html, but
that's a whole other story...)

Alec


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Setting the content type in Pylons 0.9.6

2007-09-26 Thread alecf

I think the only disappointing thing with that is the charset normally
gets stuck in there too, and I want to set that in another location...

I played around with it and I also was able to set
config['pylons.response_options']['content_type'] for a similar
effect.

Is this going a little too much behind-the scenes?

Alec



On Sep 26, 3:40 pm, James Gardner [EMAIL PROTECTED] wrote:
 Hi Alec,

 You need:

 response.headers['Content-type'] = application/atom+xml
 return render(genshi-xml, atom-feed)

 James

 alecf wrote:
  I'm trying to render some Atom feeds with Pylons -
  I've got a genshi template that more or less renders the atom feed,
  but I need to return it as application/atom+xml

  For the life of me I can't figure out how the new global response
  object works - setting content_type has no effect.. my controller
  looks something like:

  response.content_type = application/atom+xml
  response.content = render(genshi-xml, atom-feed)

  (I had to write my own 'genshi-xml' engine plugin wrapper for Genshi,
  because Genshi's default requires the file extension to be .html, but
  that's a whole other story...)

  Alec


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: mod_python configuration?

2007-05-29 Thread alecf

Wow.. I had no idea Paste could bridge the modpython divide but thanks
to your post, I just converted my own stuff over from
modpython_gateway.py, which is looks like paste.modpython derives
from...

I'm in the process of making my app more paste-friendly so I'm not
quite ready to add the .ini file, but in the mean time I'm using
paste.modpython and wsgi.application:

Location /
SetHandler python-program
PythonHandler paste.modpython
PythonOption wsgi.application client::client_app
/Location

And this works great.

Alec

On May 29, 8:44 am, Chris Shenton [EMAIL PROTECTED] wrote:
 I used mod_python about 6 months back to get Apache to proxy HTTPS to
 my Pylons app; it wasn't easy.

 Now I'm trying again with current Pylons, paste and friends.  But I'm
 again having troubles getting it to work.

 The simplest apache config I've seen is this 
 fromhttp://pythonpaste.org/module-paste.modpython.html

   SetHandler python-program
   PythonHandler paste.modpython
   PythonOption paste.ini /path/to/production.ini

 This doesn't fail but shows nothing and there is nothing logged. Any
 ideas what might be wrong (config? permissions?) or how I could get it
 to log what it's trying and failing?

 Other configs I've seen require downloading some modpython_wsgi.py
 file and then hacking it a bit, but there seem to be multiple
 different versions of this, and even more different Apache config
 styles to use it.  I've tried some and they fail, then indicate a
 .core file might have been created but it isn't so I can't diagnose it
 that way.

 So what's the current recommended way to front Pylons with mod_apache?
 Or if there are better ways to run Pylons apps behind Apache, what are
 your recommendations currently?

 Thanks.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



use of globals, threadless, and requests

2007-05-29 Thread alecf

I'm interested in serving up my pylons app under Stackless Python -
Stackless is more or less single-threaded so the model is somewhat
like Twisted but without all the deferreds. Instead of threads, there
are tasklets which participate in kind of a cooperative parallelism -
as soon as one tasklet blocks, another tasklet is allowed to run until
it blocks, and so forth.

Since this is single-threaded, I have some concerns is with these
'global' objects that Pylons provides.. c, h, etc...

These are normally thread-local storage right? Does pylons provide any
capability to either:
- provide a container so I can manage the thread-localness of them (I
could store them in a tasklet-local storage)
- provide a way to access them from environ rather than as a global?
(then I could access them on a per-request basis, independent of what
tasklet/thread they're run on)
- avoid the use of them entirely?

really I'd prefer that these things were just explicit in the request
because otherwise it really ties pylons down to a multi-threaded or
forked model. Part of the reason I'm using stackless is that I can
safely fire off multiple 'parallel' tasklets during a request which
makes management of simultaneous database requests dirt-simple.

 But maybe I'm missing something? Anyone have any ideas here?

Alec


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---