Re: redirect_to and beaker session?

2007-05-16 Thread Max Ischenko
On 5/15/07, Ben Bangert [EMAIL PROTECTED] wrote:


 Max Ischenko wrote:
  I have run into something like a bug.
 
  I'm using beaker's session and if my controller method issues a redirect
  the value I put in the session is not preserved. e.g.:
 
  session['page_message'] = message
  session.save()
  redirect_to(url_for('optima'))
 
  Anyone experienced this?

 What version of Pylons are you using? An earlier version (I believe
 0.9.3 or so) had a bug where it wasn't saved.


That was my logic error that caused session key to be popped out in
__after__.

Max.

--~--~-~--~~~---~--~~
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: Using Mako 2

2007-05-16 Thread voltron

Could someone help me out with this problem? Its a Mako template that
does not render.
Thanks


 Restarting 
Starting server in PID 2504.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
Debug at: http://localhost:5000/_debug/view/1179300848

Exception happened during processing of request from ('127.0.0.1',
1174)
Traceback (most recent call last):
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py,
line 592, in process_request_in_thread
self.finish_request(request, client_address)
  File C:\Python24\lib\SocketServer.py, line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File C:\Python24\lib\SocketServer.py, line 521, in __init__
self.handle()
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py,
line 400, in handle
BaseHTTPRequestHandler.handle(self)
  File C:\Python24\lib\BaseHTTPServer.py, line 316, in handle
self.handle_one_request()
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py,
line 395, in handle_one_request
self.wsgi_execute()
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py,
line 266, in wsgi_execute
self.wsgi_start_response)
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\cascade.py, lin
e 92, in __call__
return self.apps[-1](environ, start_response)
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\registry.py, li
ne 327, in __call__
app_iter = self.application(environ, start_response)
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\recursive.py, l
ine 80, in __call__
return self.application(environ, start_response)
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\errordocument.py
, line 185, in __call__
app_iter = self.application(environ, change_response)
  File c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\evalexception\mi
ddleware.py, line 186, in __call__
return self.respond(environ, start_response)
  File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py, l
ine 269, in respond
return debug_info.content()
  File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py, l
ine 308, in content
result = formatter_(self.exc_value)
  File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py, l
ine 288, in mako_html_data
return mako.exceptions.html_error_template().render()[610:-16]
  File c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\template.py, li
ne 109, in render
return runtime._render(self, self.callable_, args, data)
  File c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py, lin
e 286, in _render
_render_context(template, callable_, context, *args,
**_kwargs_for_callable(
callable_, data))
  File c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py, lin
e 303, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py, lin
e 336, in _exec_template
callable_(context, *args, **kwargs)
  File memory:0x124ed90, line 61, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
0: ordinal
not in range(128)



--~--~-~--~~~---~--~~
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: Using Mako 2

2007-05-16 Thread voltron

I did some poking around. This is the Pylons debug:

CompileException: Could not read template using encoding of 'ascii'.
Did you forget a magic encoding comment? in file 'D:\Projects
\Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
1 !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
2 html
3 head
4 titleF#246;n/title
5 link rel=SHORTCUT ICON href=img/favicon.ico

I tried saving the file as UTF-8, that die not help at all, the Paster
server threw an exception :

  File memory:0x128a810, line 61, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
0: ordinal
not in range(128)

Does someone have an idea on the workflow of constructing templaters
for mako from plain HTML from designers?

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



Re: myghty: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3

2007-05-16 Thread [EMAIL PROTECTED]

Actually, yes, this flag has no effect when i was trying.
But, we have resolved it. We save the .myt file into encoding utf-8,
and add a line to the top of the myt file:

# encoding: utf-8

The Myghty will add the line into the translated .myt.py file like
this:

# File: templates|base.myt CompilerID: Myghty.Lexer|Myghty.Compiler|
(5, {'disable_unicode': False}) Timestamp: Wed May 16 16:12:52 2007
# -*- encoding: utf-8 -*-

so, everything is ok.

On Apr 5, 11:07 pm, Chris Shenton [EMAIL PROTECTED] wrote:
 Using Pylons-0l9.4.1 and Myghty-1.1.  I can't seem to set encoding to
 utf-8 for Myghty or mod_python so that Pylons gets it.

 My app was working well but just started bombing, likely because one
 of my techs entered a name into a form which had non-ascii chars, and
 then the rendering in the display failed.  When I run with debug
 enabled, I get a bit more info:

 Error: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3
 in position 15: ordinal not in range(128)
 File: /usr/local/clientproj/er/templates/vendor_show.myt line 11
 Context: 8:
 trthClient Name/ththUpdated/ththCreated/th/tr
 9: %   for client in c.clients:
 10: tr
 11:   tda href=%h.url_for('client_show', 
 client_id=client.client_id)%%client.name%/a/td
 12:   td%client.ts_updated%/td
 13:   td%client.ts_created%/td
 14: /tr

 Error - myghty.exception.Error: Error(UnicodeDecodeError?):
 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not
 in range(128) at
 
 /usr/local/lib/python2.4/site-packages/Myghty-1.1-py2.4.egg/myghty/requestbuffer.py
 line 367

 I've read up on this and found suggestions in

  http://www.myghty.org/docs/params.myt#parameters_output_encoding

 to set encoding in config/environment.py, which I've done:

 myghty = {}
 myghty['log_errors'] = True
 myghty['escapes'] = dict(l=webhelpers.auto_link, 
 s=webhelpers.simple_format)

 myghty['output_encoding'] = 'utf-8'
 myghty['encoding_errors'] = 'htmlentityreplace'

 return pylons.config.Config(myghty, map, paths)

 but this didn't help. The error continued to complain about ascii
 codec so it looks like this setting above isn't getting seen by
 myghty.  It also suggested setting this in the mod_python section of
 my Apache config, which I also tried:

 Location /er
 SetHandler  mod_python
 Pythonhandler   mod_python.wsgi
 PythonPath  ['/usr/local/clientjob] + sys.path
 PythonOptionwsgi.application startup-bluecoat::app
 PythonOptionSCRIPT_NAME /er
 # 2007-04-05 setting in config/environment.py isnt' working?
 PythonOption MyghtyOutputEncoding   utf-8
 PythonOption MyghtyEncodingErrors   
 htmlentityreplace
 /Location

 But this also had no effect, same complaint about ascii.

 http://pylonshq.com/docs/internationalization.htmlsaid I could do the
 following, again in config/environment.py:

tmpl_options['myghty.output_encoding'] = 'UTF-8'

 but that file didn't know about the tmpl_options dict.

 I've seen similar suggestion to the above in a #pylons IRC transcript
 but none of these are working for me.  Why is it still using an
 ascii codec when I've set it in two different places?

 I've tried removing the template cache .py and .pyc files but that had
 no effect.

 I was finally able to get things to work by creating
 .../site-packages/sitecustomize.py:

 import sys
 sys.setdefaultencoding('utf-8')

 and saw that one of my clients names was an O-umlaut.  (Should I now
 expect surprises from other things, like the fact that I'm not using
 unicode strings in my python?)

 I'd really like to do this in Pylons or Myghty instead than site-wide
 and don't understand why the documented mechanisms don't work for me.

 Any suggestions? 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
-~--~~~~--~~--~--~---



Re: Bug with beaker.cache ?

2007-05-16 Thread Alexandre CONRAD

Michael Bayer wrote:

 has_key passes unit tests added in rev 70, using DBM files like your  
 example, im fairly certain this worked in older versions so you might  
 want to double check your cache expiry/etc. and/or upgrade to beaker  
 trunk; fixed/added support for unicode keys in rev 71.

I've updated to the Beaker-0.7dev_r71-py2.4.egg. I had to change some 
import statments in pylons/wsgiapp.py because SessionMiddleware and 
CacheMiddleware were moved over in beaker/middleware.py.

Then start the Pylons' command-line shell:

   paster shell development.ini

So the unicode fix works fine now. But I'm still having trouble with the 
  has_key, eventhough, the behaviour has changed a bit:

  cache.get_cache(users).set_value(anonymous, bla)
  cache.get_cache(users).get_value(anonymous)
'bla'
  cache.get_cache(users).has_key(anonymous)
False
  cache.get_cache(users).has_key(foo) # was previously returning 0
False
  anonymous in cache.get_cache(users)
False
  foo in cache.get_cache(users)
False

This is raw from the command line. There's no expire set anywhere. And 
it all returns `False` even if a key really exists.

[... much later ...]

I have found out where my problem came from. It turns out that if I do 
the following, it works fine (inspired from your unit tests):

  _cache = cache.get_cache(users)
  _cache.set_value(anonymous, bla)
  _cache.get_value(anonymous)
'bla'
  _cache.has_key(anonymous)
True
  _cache.has_key(foo)
False
  anonymous in _cache
True
  foo in _cache
False

I noticed that pylons cache object (beaker.cache.CacheManager) returns 
a different beaker.cache.Cache object everytime:

  cache.get_cache(users)
beaker.cache.Cache object at 0x12543d0
  cache.get_cache(users)
beaker.cache.Cache object at 0x1244410
  cache.get_cache(users)
beaker.cache.Cache object at 0x1254490
  cache.get_cache(users)
beaker.cache.Cache object at 0x1254410
  cache.get_cache(users)
beaker.cache.Cache object at 0x1244410
  cache.get_cache(users)
beaker.cache.Cache object at 0x12543d0
  cache.get_cache(users)
beaker.cache.Cache object at 0x1254490

Actually, it seems to randomly return a previously returned object. It's 
pretty confusing. Doing a .get_value(anonymous) always returns the 
correct information, but the .has_key() method doesn't work.

Am I missing something ?

Regards,
-- 
Alexandre CONRAD


--~--~-~--~~~---~--~~
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: Using Mako 2

2007-05-16 Thread [EMAIL PROTECTED]



On 16 mai, 10:03, voltron [EMAIL PROTECTED] wrote:
 I did some poking around. This is the Pylons debug:

 CompileException: Could not read template using encoding of 'ascii'.
 Did you forget a magic encoding comment? in file 'D:\Projects
 \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
 1 !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 http://www.w3.org/TR/html4/loose.dtd;
 2 html
 3 head
 4 titleF#246;n/title
 5 link rel=SHORTCUT ICON href=img/favicon.ico

 I tried saving the file as UTF-8, that die not help at all, the Paster
 server threw an exception :

   File memory:0x128a810, line 61, in render_body
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
 0: ordinal
 not in range(128)


You may want to reads this:
http://docs.pythonweb.org/display/pylonscookbook/Using+Mako+templating+language

 Does someone have an idea on the workflow of constructing templaters
 for mako from plain HTML from designers?

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



Re: myghty: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3

2007-05-16 Thread voltron

Hi Steve, this is good information as it is a good workaround for the
problem that I have been having with my Mako templates with
Umlauts( see thread 
http://groups.google.com/group/pylons-discuss/browse_thread/thread/4d278dee35c62519)

I´m just worried that it seems like a hack and not the official way to
set things in Pylons.


On May 16, 10:18 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Actually, yes, this flag has no effect when i was trying.
 But, we have resolved it. We save the .myt file into encoding utf-8,
 and add a line to the top of the myt file:

 # encoding: utf-8

 The Myghty will add the line into the translated .myt.py file like
 this:

 # File: templates|base.myt CompilerID: Myghty.Lexer|Myghty.Compiler|
 (5, {'disable_unicode': False}) Timestamp: Wed May 16 16:12:52 2007
 # -*- encoding: utf-8 -*-

 so, everything is ok.

 On Apr 5, 11:07 pm, Chris Shenton [EMAIL PROTECTED] wrote:

  Using Pylons-0l9.4.1 and Myghty-1.1.  I can't seem to set encoding to
  utf-8 for Myghty or mod_python so that Pylons gets it.

  My app was working well but just started bombing, likely because one
  of my techs entered a name into a form which had non-ascii chars, and
  then the rendering in the display failed.  When I run with debug
  enabled, I get a bit more info:

  Error: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3
  in position 15: ordinal not in range(128)
  File: /usr/local/clientproj/er/templates/vendor_show.myt line 11
  Context: 8:
  trthClient Name/ththUpdated/ththCreated/th/tr
  9: %   for client in c.clients:
  10: tr
  11:   tda href=%h.url_for('client_show', 
  client_id=client.client_id)%%client.name%/a/td
  12:   td%client.ts_updated%/td
  13:   td%client.ts_created%/td
  14: /tr

  Error - myghty.exception.Error: Error(UnicodeDecodeError?):
  'ascii' codec can't decode byte 0xc3 in position 15: ordinal not
  in range(128) at
  
  /usr/local/lib/python2.4/site-packages/Myghty-1.1-py2.4.egg/myghty/requestbuffer.py
  line 367

  I've read up on this and found suggestions in

   http://www.myghty.org/docs/params.myt#parameters_output_encoding

  to set encoding in config/environment.py, which I've done:

  myghty = {}
  myghty['log_errors'] = True
  myghty['escapes'] = dict(l=webhelpers.auto_link, 
  s=webhelpers.simple_format)

  myghty['output_encoding'] = 'utf-8'
  myghty['encoding_errors'] = 'htmlentityreplace'

  return pylons.config.Config(myghty, map, paths)

  but this didn't help. The error continued to complain about ascii
  codec so it looks like this setting above isn't getting seen by
  myghty.  It also suggested setting this in the mod_python section of
  my Apache config, which I also tried:

  Location /er
  SetHandler  mod_python
  Pythonhandler   mod_python.wsgi
  PythonPath  ['/usr/local/clientjob] + sys.path
  PythonOptionwsgi.application startup-bluecoat::app
  PythonOptionSCRIPT_NAME /er
  # 2007-04-05 setting in config/environment.py isnt' working?
  PythonOption MyghtyOutputEncoding   utf-8
  PythonOption MyghtyEncodingErrors   
  htmlentityreplace
  /Location

  But this also had no effect, same complaint about ascii.

 http://pylonshq.com/docs/internationalization.htmlsaidI could do the
  following, again in config/environment.py:

 tmpl_options['myghty.output_encoding'] = 'UTF-8'

  but that file didn't know about the tmpl_options dict.

  I've seen similar suggestion to the above in a #pylons IRC transcript
  but none of these are working for me.  Why is it still using an
  ascii codec when I've set it in two different places?

  I've tried removing the template cache .py and .pyc files but that had
  no effect.

  I was finally able to get things to work by creating
  .../site-packages/sitecustomize.py:

  import sys
  sys.setdefaultencoding('utf-8')

  and saw that one of my clients names was an O-umlaut.  (Should I now
  expect surprises from other things, like the fact that I'm not using
  unicode strings in my python?)

  I'd really like to do this in Pylons or Myghty instead than site-wide
  and don't understand why the documented mechanisms don't work for me.

  Any suggestions? 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
-~--~~~~--~~--~--~---



Re: Using Mako 2

2007-05-16 Thread voltron

Thanks Bruno, I have read that. In a thread a few days ago I asked
questions about it, see this thread:

http://groups.google.com/group/pylons-discuss/browse_thread/thread/bceff9ef23772e5d/35aa3a21e4ce3e43?lnk=stq=rnum=30#35aa3a21e4ce3e43

The thing is, in the thread, 2 people mentioned that it was
unnecessary, which is true when one does not use umlauts



On May 16, 12:14 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On 16 mai, 10:03, voltron [EMAIL PROTECTED] wrote:



  I did some poking around. This is the Pylons debug:

  CompileException: Could not read template using encoding of 'ascii'.
  Did you forget a magic encoding comment? in file 'D:\Projects
  \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
  1 !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  http://www.w3.org/TR/html4/loose.dtd;
  2 html
  3 head
  4 titleF#246;n/title
  5 link rel=SHORTCUT ICON href=img/favicon.ico

  I tried saving the file as UTF-8, that die not help at all, the Paster
  server threw an exception :

File memory:0x128a810, line 61, in render_body
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
  0: ordinal
  not in range(128)

 You may want to reads 
 this:http://docs.pythonweb.org/display/pylonscookbook/Using+Mako+templatin...

  Does someone have an idea on the workflow of constructing templaters
  for mako from plain HTML from designers?

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



Re: myghty: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3

2007-05-16 Thread Jens Hoffrichter

On 5/16/07, voltron [EMAIL PROTECTED] wrote:

 Hi Steve, this is good information as it is a good workaround for the
 problem that I have been having with my Mako templates with
 Umlauts( see thread 
 http://groups.google.com/group/pylons-discuss/browse_thread/thread/4d278dee35c62519)

 I´m just worried that it seems like a hack and not the official way to
 set things in Pylons.
Maybe it is not officially declared in Pylons, but it is for sure the
correct way to set the encoding for a Python file, in general.

But working with UTF-8 and Unicode can sometimes be a real pain in
Python. I resorted to setting the site.py on all sites I manage to
UTF-8, but it is a very cumbersome solution.

Jens

--~--~-~--~~~---~--~~
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: myghty: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3

2007-05-16 Thread voltron

Oh I did not know about that, thanks Jens. Excuse my newbiness, but
could you explain your method further? where is site.py?

Thanks

On May 16, 1:13 pm, Jens Hoffrichter [EMAIL PROTECTED]
wrote:
 On 5/16/07, voltron [EMAIL PROTECTED] wrote:

  Hi Steve, this is good information as it is a good workaround for the
  problem that I have been having with my Mako templates with
  Umlauts( see 
  threadhttp://groups.google.com/group/pylons-discuss/browse_thread/thread/4d...)

  I´m just worried that it seems like a hack and not the official way to
  set things in Pylons.

 Maybe it is not officially declared in Pylons, but it is for sure the
 correct way to set the encoding for a Python file, in general.

 But working with UTF-8 and Unicode can sometimes be a real pain in
 Python. I resorted to setting the site.py on all sites I manage to
 UTF-8, but it is a very cumbersome solution.

 Jens


--~--~-~--~~~---~--~~
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: Pylons (Kid? Paste?) converting my XHTML to HTML

2007-05-16 Thread [EMAIL PROTECTED]

Sorry to spam the list, but eventually I resolved the problem - for
future readers I suggest updating the modules Pylons, Paste,
PasteScript Kid and TurboKid to the latest versions.

For some reason PasteScript didn't want to update to 1.3 through
easy_install -U so downloading the source and running python setup.py
install and manually removing 1.1 did the trick.

Ben was right in that format=xhtml is the way to do it, but some
combination of the different modules I had meant that did not work.
I'm guessing it is related to my earlier install of TurboGears since
some of the modules are shared, so I ended up with muddled versions.

Cheers,
Ben

On May 14, 9:12 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 In addition to the above I changed middleware.py to have the
 following:

 config.template_engines.pop()#remove myghty
 kidopts = {'kid.outputformat':'xhtml','kid.assume_encoding':'utf-8',
 'kid.encoding':'utf-8'}
 config.add_template_engine('kid', 'familiarsserver.templates',
 kidopts)

 according to the example 
 athttp://pylonshq.com/docs/0.9.5/class-pylons.config.Config.html

 The 'kid.outputformat':'xhtml' is a turbogears option for TurboKid
 which I see is the format Pylons also uses, so I presume it would be
 passed on to Kid in the same way.

 However, this still has no effect. Even changing outputformat to xml
 also has no effect. Is there something I'm still missing? Maybe I'm
 using that outputformat option wrong? Or a poor configuration is
 causing it to fall back on html as a default?

 I'm pretty lost here, but I think I'm closer, and also think it's
 something in how the templating options are set up.

 Cheers again
 Ben

 On May 14, 3:18 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

  Cheers for the suggestion but it doesn't seem to have any effect.

  I realise I'm probably posting in the wrong group, but I'd rather let
  Pylons take care of Kid so any Pylons solution is going to be easier
  (rather than wrangling Kid directly and bypassing Pylons here). I'm
  confident it's probably me not configuring something correctly...

  I've noticed that I get an error if Kid detects I've entered invalid
  XML in my template file. I presume that this validation process must
  be close to the bit that is doing the conversion.
  I input an invalid tag and get the following stack trace:

  The function call is, as suggested,
  render_response(template,format=xhtml)

 http://pylonshq.com/pasties/259

  To my inexperienced eyes it looks like from line 45 Kid is parsing my
  template and running the python code, so I presume it is somewhere
  around there that the conversion happens, but I can't see where.

  For reference, my middleware.py uses this line to tell pylons to use
  Kid:
  config.init_app(global_conf, app_conf, package='myapplication',
  template_engine='kid')

  I notice this line in environment.py:
  # The following template options are passed to your template engines
  tmpl_options = {}
  Adding 'format':'xhtml' doesn't make a difference here either.

  There is nothing in development.ini that refers to Kid or templating
  options

  Sorry again about posting this to the pylons group but I'm convinced
  there are some Pylons configuration options that might fix it if only
  I knew where to look :)

  Cheers for patience,
  Ben

  On May 1, 6:31 pm, Ben Bangert [EMAIL PROTECTED] wrote:

   On May 1, 2007, at 8:49 AM, [EMAIL PROTECTED] wrote:

All my kid templates work great, but they seem to be parsed through
some kind of filter (pylons is using HTMLSerializer from Kid maybe?)
that converts all my tags into HTML 4.01 versions: title becomes
TITLE and img src=blah / becomes IMG SRC=blah

what is it that is doing this? Is there some way for me to switch it
to spit outXHTML? or just to preferably leave my code as I wrote it?
It worries me that the server is going through this extra conversion
process for every page it renders.

   I believe this is Kid doing that. Pylons has no output filtering of
   its own. You probably need to specify a default format for Kid of
  xhtml(though I'm pretty certain that the Pylons Kid defaults already
   set the format toxhtml...).

   Alternatively, you can specify format='xhtml' to render_response or
   render which should be passed to Kid.

   HTH,
   Ben


--~--~-~--~~~---~--~~
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: myghty: Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3

2007-05-16 Thread voltron

Cool, thanks!

On May 16, 2:26 pm, Jens Hoffrichter [EMAIL PROTECTED]
wrote:
 Hey Voltron,

 On 5/16/07, voltron [EMAIL PROTECTED] wrote:

  Oh I did not know about that, thanks Jens. Excuse my newbiness, but
  could you explain your method further? where is site.py?

 The declaration for working with encodings in Python files is
 described here, in PEP 263:

 http://www.python.org/dev/peps/pep-0263/

 The site.py is normally located in your base library directory, for me
 on Debian Linux it is
 /usr/lib/python2.4, or maybe even /etc/python2.4/site.py

 Search for the string ascii in the file, and then you can see why it
 is very hard to change the default encoding after this file is
 executed. And site.py is automagically executed everytime you start
 python ;)

 But, as I said, it is cumbersome, because you must have access to the
 site.py file, and this isn't guaranteed, especially for a shared
 hoster.

 There exists another solution, at least for normal python applications:

 You can place a file called sitecustomize.py in the directory of
 your application (or maybe in the first library path for it, I'm not
 sure, but that is normally the application path), where you can put in
 something like that:

  snip 
 import sys

 sys.setdefaultencoding(UTF-8)
  snip 

 This works as well. I normally don't use it, and especially haven't
 used it with pylons (because I'm actually on this list because I had a
 Myghty caching question, and somehow stayed ;) ), but this is the only
 solution python applications compiled with py2exe, as you have no
 other method of setting the site.py there.

 But, as I said, I don't know how it would work in pylons, maybe
 someone with a broader knowledge in pylons can look at it.

 Jens


--~--~-~--~~~---~--~~
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: Iteration in Mako templates

2007-05-16 Thread voltron

nevermind

table
% for item in c.links:
tr
   td${item}/td
/tr
% endfor
  /table




On May 16, 4:02 pm, voltron [EMAIL PROTECTED] wrote:
 Hi,

 I tnink this is for the Pylons group and not Mako, if I´m mistaken, I
 apologize

 given:

 c.links =[link1, link2, link3]

 table
 % for item in c.links:
 tr
tdc.links[item]}/td
 /tr
 % endfor
   /table

 How do I iterate over the list? My code above does not work.

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



Re: Iteration in Mako templates

2007-05-16 Thread Dan

You do have syntax error at:
tdc.links[item]}/td
should be:
td${c.links[item]}/td

I believe this is what you want... assuming that c.links is being declared in 
your controller!
#controller
def some_action(self):
c.links = [link1,link2,link3]
return render_response('/some_template.mak')

#some_template.mak

table
% for item in c.links:
tr
  td${item}/td
/tr
% endfor
/table


voltron wrote:
 Hi,

 I tnink this is for the Pylons group and not Mako, if I´m mistaken, I
 apologize

 given:

 c.links =[link1, link2, link3]

 table
 % for item in c.links:
 tr
tdc.links[item]}/td
 /tr
 % endfor
   /table

 How do I iterate over the list? My code above does not work.


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



Re: Iteration in Mako templates

2007-05-16 Thread Alexandre CONRAD

voltron wrote:
 nevermind
 
 table
 % for item in c.links:
 tr
td${item}/td
 /tr
 % endfor
   /table

Nothing to do about your initial problem, but by reading your HTML, I 
can only suggest that you'd probably prefer using HTML unordered lists 
ul, list items li and format the output with CSS instead of using 
tables.

ul
   % for item in c.links:
 li${item}/li
   % endfor
/ul

I like to point this link once in a while:

   http://hotdesign.com/seybold/everything.html

Regards,
-- 
Alexandre CONRAD


--~--~-~--~~~---~--~~
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: Iteration in Mako templates

2007-05-16 Thread Dan

You do have syntax error at:
tdc.links[item]}/td
should be:
td${c.links[item]}/td

I believe this is what you want... assuming that c.links is being declared in 
your controller!
#controller
def some_action(self):
c.links = [link1,link2,link3]
return render_response('/some_template.mak')

#some_template.mak

table
% for item in c.links:
tr
  td${item}/td
/tr
% endfor
/table


voltron wrote:
 Hi,

 I tnink this is for the Pylons group and not Mako, if I´m mistaken, I
 apologize

 given:

 c.links =[link1, link2, link3]

 table
 % for item in c.links:
 tr
tdc.links[item]}/td
 /tr
 % endfor
   /table

 How do I iterate over the list? My code above does not work.


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



Re: Iteration in Mako templates

2007-05-16 Thread voltron

Yes, actually, the code which I first posted is from the tutorial, my
real production code looks like this:

div class=submenu_center
  ul class=submenu
 % for item in c.sublinks:
lia href=${item}/ class=level_submenu${item}/
a/li
 % endfor
  /ul
/div


Thank you all for the tips

On May 16, 4:20 pm, Alexandre CONRAD [EMAIL PROTECTED] wrote:
 voltron wrote:
  nevermind

  table
  % for item in c.links:
  tr
 td${item}/td
  /tr
  % endfor
/table

 Nothing to do about your initial problem, but by reading your HTML, I
 can only suggest that you'd probably prefer using HTML unordered lists
 ul, list items li and format the output with CSS instead of using
 tables.

 ul
% for item in c.links:
  li${item}/li
% endfor
 /ul

 I like to point this link once in a while:

http://hotdesign.com/seybold/everything.html

 Regards,
 --
 Alexandre CONRAD


--~--~-~--~~~---~--~~
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: paster shell not available

2007-05-16 Thread Alberto Valverde


On May 16, 2007, at 11:09 AM, Max Ischenko wrote:



 Here is the question: where is paster shell command hooked in?

 When I attempt to use paster shell in my current project I got this:

 $ paster shell development.ini
 Command shell not known
 Known commands:

 Newly created Pylons projects have this functionality working so I
 guess I need to upgrade something in my existing project to get this
 command.

Make sure there's a file called paster_plugins.txt inside your  
egg_info directory with, at least, the following lines:

Pylons
PasteScript

Alberto

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



Issues with @validate decorator

2007-05-16 Thread Graham Stratton

Hi all,

I see there's discussion about the issues with the @validate decorator
in the tracker.  I've come across a few problems myself in the last
few weeks, so hopefully I can contribute here:

- In order to use multiple fields, you need to set variable_decode to
True.  This is probably fair enough, and it probably ought to be the
default. It does have other side effects for field names containing
'-' or '.'   Making variable_decode True by default is certainly not a
backwards-compatible change.

- In order to use htmlfill with multiples, params also needs to be
mapped from a MultiDict. At present htmlfill called from the decorator
only selects the first value for fields with multiple values.  I think
this can be fixed by passing decoded instead of params to htmlfill.

- It's worth noting that line 98 tests for the type of params, and if
it is a UnicodeMultiDict decodes the page to unicode.  So any playing
around with params needs to preserve its type.  This doesn't feel
right to me.

- Specifying separate validators (as opposed to a schema) fails if no
value is passed for a multiple.  I suspect that line 90:

validator.to_python(decoded[field] or None)

should read

validator.to_python(decoded.get(field, None))

Regards,

Graham


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



Calling in-line classes with routes

2007-05-16 Thread voltron

Given:
# snippet

from gameolymp.lib.base import *


class NavigationController(BaseController):
def index(self):
return render_response('base')
class InnerClass(BaseController):
def index(self):
return Response('innner')

How would I route the inner class?

  map.connect('spiele', '', controller='navigation.innerclass',
action='index' )

does not work. 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
-~--~~~~--~~--~--~---



Re: Iteration in Mako templates

2007-05-16 Thread Dan





The choice between CSS 'tables' and HTML 'tables' is purely a matter of
opinion.

Just to point out a totally different point-of-view, please see:

http://www.decloak.com/Dev/CSSTables/CSS_Tables_01.aspx

Alexandre CONRAD wrote:

  voltron wrote:
  
  
nevermind

table
% for item in c.links:
tr
   td${item}/td
/tr
% endfor
  /table

  
  
Nothing to do about your initial problem, but by reading your HTML, I 
can only suggest that you'd probably prefer using HTML unordered lists 
ul, list items li and format the output with CSS instead of using 
tables.

ul
   % for item in c.links:
 li${item}/li
   % endfor
/ul

I like to point this link once in a while:

   http://hotdesign.com/seybold/everything.html

Regards,
  


--~--~-~--~~~---~--~~
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: Calling in-line classes with routes

2007-05-16 Thread voltron

Nevermind



On May 16, 4:58 pm, voltron [EMAIL PROTECTED] wrote:
 Given:
 # snippet

 from gameolymp.lib.base import *

 class NavigationController(BaseController):
 def index(self):
 return render_response('base')
 class InnerClass(BaseController):
 def index(self):
 return Response('innner')

 How would I route the inner class?

   map.connect('spiele', '', controller='navigation.innerclass',
 action='index' )

 does not work. 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
-~--~~~~--~~--~--~---



Re: Iteration in Mako templates

2007-05-16 Thread Michael Bayer

On May 16, 2007, at 12:34 PM, Dan wrote:

 The choice between CSS 'tables' and HTML 'tables' is purely a  
 matter of opinion.

 Just to point out a totally different point-of-view, please see:

 http://www.decloak.com/Dev/CSSTables/CSS_Tables_01.aspx


theres an argument to use table tags for sure...but that guy's nuts.




--~--~-~--~~~---~--~~
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: Using Mako 2

2007-05-16 Thread Philip Jenvey


On May 16, 2007, at 1:03 AM, voltron wrote:


 I did some poking around. This is the Pylons debug:

 CompileException: Could not read template using encoding of 'ascii'.
 Did you forget a magic encoding comment? in file 'D:\Projects
 \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
 1 !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 http://www.w3.org/TR/html4/loose.dtd;
 2 html
 3 head
 4 titleF#246;n/title
 5 link rel=SHORTCUT ICON href=img/favicon.ico

You definitely need a magic encoding comment because there's non- 
ascii characters in your template.


 I tried saving the file as UTF-8, that die not help at all, the Paster
 server threw an exception :

Did you include the magic encoding comment when you did this? Some  
editors will also use the utf-8 bom at the beginning of a file to  
identify mark the file as being in utf-8 (so a magic encoding comment  
isn't required). Python supports the utf-8 bom for .py files, however  
mako only started supporting identifying the utf-8 bom in the latest  
version (trunk).


   File memory:0x128a810, line 61, in render_body
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
 0: ordinal
 not in range(128)

 Does someone have an idea on the workflow of constructing templaters
 for mako from plain HTML from designers?


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



Re: Iteration in Mako templates

2007-05-16 Thread Cliff Wells

On Wed, 2007-05-16 at 14:10 -0400, Michael Bayer wrote:
 
 On May 16, 2007, at 12:34 PM, Dan wrote:
 
  The choice between CSS 'tables' and HTML 'tables' is purely a matter
  of opinion.
  
  Just to point out a totally different point-of-view, please see:
  
  http://www.decloak.com/Dev/CSSTables/CSS_Tables_01.aspx
  
 
 
 theres an argument to use table tags for sure...but that guy's nuts.


Nuts is being kind.

Cliff
 


--~--~-~--~~~---~--~~
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: Iteration in Mako templates

2007-05-16 Thread Dan

Lol.  The other article was just as fanatical, using cartoon images to 
persuade the reader into thinking CSS was the best thing since 'sliced 
bread'.  To be fair, I'd say they are both nuts.

Michael Bayer wrote:

 On May 16, 2007, at 12:34 PM, Dan wrote:

 The choice between CSS 'tables' and HTML 'tables' is purely a matter 
 of opinion.

 Just to point out a totally different point-of-view, please see:

 http://www.decloak.com/Dev/CSSTables/CSS_Tables_01.aspx


 theres an argument to use table tags for sure...but that guy's nuts.




 

--~--~-~--~~~---~--~~
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: Issues with @validate decorator

2007-05-16 Thread Philip Jenvey


On May 16, 2007, at 7:51 AM, Graham Stratton wrote:


 Hi all,

 I see there's discussion about the issues with the @validate decorator
 in the tracker.  I've come across a few problems myself in the last
 few weeks, so hopefully I can contribute here:

 - In order to use multiple fields, you need to set variable_decode to
 True.  This is probably fair enough, and it probably ought to be the
 default. It does have other side effects for field names containing
 '-' or '.'   Making variable_decode True by default is certainly not a
 backwards-compatible change.

 - In order to use htmlfill with multiples, params also needs to be
 mapped from a MultiDict. At present htmlfill called from the decorator
 only selects the first value for fields with multiple values.  I think
 this can be fixed by passing decoded instead of params to htmlfill.

Decoded as in variable_decode=True again, right?

Defaulting variable_decode to True was brought up a long time ago but  
it never happened. I don't think everyone (at least I didn't)  
realized there were so many cases in which formencode doesn't work  
with MultiDicts unless variable_decode is enabled.

The fact that variable_decode=True fixes the MultiDict problems is  
more of a coincidence. The variable_decode function is supposed to  
flatten/de-nest a normal dictionary with '-' and '.' separators, the  
fact that it correctly flattens a MultiDict is almost a side effect.

The flattening it does is essentially the same result as having  
called MultiDict.mixed(). validate passing MultiDict.mixed() to  
formencode would be an even better solution than defaulting  
variable_decode=True. The qualm I have with doing any of these is  
that Pylons/Paste users that aren't using the validate decorator need  
to know to use MultiDict.mixed() or variable_decode=True.

It's reasonable to require variable_decode=True if you're using the  
'-' and '.' nesting syntax. But if you're not, I'd rather MultiDicts  
Just Worked(tm).

I spoke to Ian (who I've CCed) about MultiDicts and formencode a  
while ago. I got the impression from him that he wanted MultiDicts to  
Just Work(tm) with formencode. Ian, what's your opinion on all this?


 - It's worth noting that line 98 tests for the type of params, and if
 it is a UnicodeMultiDict decodes the page to unicode.  So any playing
 around with params needs to preserve its type.  This doesn't feel
 right to me.

What doesn't feel right exactly?


 - Specifying separate validators (as opposed to a schema) fails if no
 value is passed for a multiple.  I suspect that line 90:

 validator.to_python(decoded[field] or None)

 should read

 validator.to_python(decoded.get(field, None))

You're right, in fact this should probably be a getall() instead of a  
normal get() (depending on how we solve variable_decode issue anyway).


 Regards,

 Graham


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



Re: Iteration in Mako templates

2007-05-16 Thread skip . montanaro


dan To be fair, I'd say they are both nuts.

Hmmm...  I wonder if they are friends? ;-)

-- 
Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/

--~--~-~--~~~---~--~~
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: Issues with @validate decorator

2007-05-16 Thread Ian Bicking

Philip Jenvey wrote:
 
 On May 16, 2007, at 7:51 AM, Graham Stratton wrote:
 

 Hi all,

 I see there's discussion about the issues with the @validate decorator
 in the tracker.  I've come across a few problems myself in the last
 few weeks, so hopefully I can contribute here:

 - In order to use multiple fields, you need to set variable_decode to
 True.  This is probably fair enough, and it probably ought to be the
 default. It does have other side effects for field names containing
 '-' or '.'   Making variable_decode True by default is certainly not a
 backwards-compatible change.

 - In order to use htmlfill with multiples, params also needs to be
 mapped from a MultiDict. At present htmlfill called from the decorator
 only selects the first value for fields with multiple values.  I think
 this can be fixed by passing decoded instead of params to htmlfill.
 
 Decoded as in variable_decode=True again, right?
 
 Defaulting variable_decode to True was brought up a long time ago but it 
 never happened. I don't think everyone (at least I didn't) realized 
 there were so many cases in which formencode doesn't work with 
 MultiDicts unless variable_decode is enabled.
 
 The fact that variable_decode=True fixes the MultiDict problems is more 
 of a coincidence. The variable_decode function is supposed to 
 flatten/de-nest a normal dictionary with '-' and '.' separators, the 
 fact that it correctly flattens a MultiDict is almost a side effect.
 
 The flattening it does is essentially the same result as having called 
 MultiDict.mixed(). validate passing MultiDict.mixed() to formencode 
 would be an even better solution than defaulting variable_decode=True. 
 The qualm I have with doing any of these is that Pylons/Paste users that 
 aren't using the validate decorator need to know to use 
 MultiDict.mixed() or variable_decode=True.
 
 It's reasonable to require variable_decode=True if you're using the '-' 
 and '.' nesting syntax. But if you're not, I'd rather MultiDicts Just 
 Worked(tm).
 
 I spoke to Ian (who I've CCed) about MultiDicts and formencode a while 
 ago. I got the impression from him that he wanted MultiDicts to Just 
 Work(tm) with formencode. Ian, what's your opinion on all this?

Yeah, I think that's reasonable.  Really FormEncode is intended to work 
with, um, params.mixed()?  FormEncode could just check for that 
attribute in schemas and call it if it's there.

   Ian


--~--~-~--~~~---~--~~
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: Error with myghty request processing unicode

2007-05-16 Thread Philip Jenvey


On May 15, 2007, at 3:22 PM, Victor Kryukov wrote:


 Hi group,

 I've just installed pylons yesterday, so I apologize if the question
 I'm asking is too trivial.

 Here it is: I tried to redefine TemplateController as suggested in
 it's documentation string:

 from ljeye.lib.base import *
 import myghty.exception

 class TemplateController(BaseController):
 def view(self, url):
 try:
 return render_response('/'+url)
 except myghty.exception.ComponentNotFound:
 return Response(code=404)

 I also placed file called 'help.myt' under /templates.

 Now, when I'm trying to access localhost:5000/help.myt, I'm getting
 the following error:

 Error(AttributeError): 'unicode' object has no attribute
 'is_file_component'

 The reason for this error lies in the way Myghty handles unicode
 components:

 Error:
 Error(AttributeError): 'unicode' object has no attribute
 'is_file_component'
 File:
 /usr/lib/python2.5/site-packages/Myghty-1.1-py2.5.egg/myghty/
 request.py line 227
 Context:
 224: try:
 225: if type(component) == types.StringType:
 226: component =
 self.fetch_lead_component(component)
 227: elif component.is_file_component():
 228: self.request_path = component.path
 229:
 230: self.request_component = component

 For some reason, component in my case is u'help.myt', and hence the
 type(component)==types.StringType comparison failes.

 Note that I'm using freshly downloaded 0.9.5 Pylons, python2.5 etc.,
 and I'm just playing with freshly created pylons project.

 I would appreciate if you could clarify that for me.


This is a funny new bug with the TemplateController and the latest  
version of routes required by Pylons 0.9.5. Routes now gives you back  
unicode values -- in this case the url passed to the  
TemplateController's action is unicode. And unfortunately Myghty has  
trouble with a component name in unicode.

There's a few ways to solve this:

o (the easiest) convert the url back to a string yourself:
 return render_response('/'+str(url))

or even:

 return render_response('/'+url.encode('utf-8'))

o upgrade to the experimental routes trunk that offers a couple ways  
of turning off unicode:
  - switch the encoding setting to None in your mapper:
 mapper = Mapper()
 mapper.encoding = None

  - switch the encoding off for the particular route:
 map.connect('*url', controller='template', action='view',  
_encoding=None)

I've logged a ticket for it here: http://pylonshq.com/project/ 
pylonshq/ticket/242

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



Re: Issues with @validate decorator

2007-05-16 Thread Max Ischenko
Hello,

On 5/16/07, Graham Stratton [EMAIL PROTECTED] wrote:


 Hi all,

 I see there's discussion about the issues with the @validate decorator
 in the tracker.  I've come across a few problems myself in the last
 few weeks, so hopefully I can contribute here:


I have another @validate issue (totally unrelated to the discussion):

When there are errors and form is redisplayed to the user how the template
can tell it (to display something like there were errors, please correct
and resubmit)? From what I gather, htmlfill only fills individual fields'
placeholders but there is no form-wide one. Am i mistaken? If not, why
aren't errors passed as c.form_errors or something?

Max.

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