Re: challenges while upgrading to 0.9.7

2009-05-25 Thread Shannon -jj Behrens

On Fri, May 22, 2009 at 2:33 AM, Shannon -jj Behrens jji...@gmail.com wrote:
 I have a project in production, and I decided to upgrade my app from
 0.9.6.1 to 0.9.7.  I read all the docs related to upgrading.  I
 decided to use paster create myapp -t pylons to upgrade my project.
 These are the headaches I encountered:

  * Warn people that if they use paster create to upgrade their project, they
   probably don't want to override base.py.  After all, paster create doesn't
   update your controllers, and my controllers depended on the imports in
   base.py.

  * AttributeError: 'module' object has no attribute 'url_for'
   I was using h.url_for in a controller.  It's even mentioned in
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779
   (which is probably a bug).  I didn't find any mention in the upgrading docs
   that this was gone.  I added from routes import url_for to my helpers.py.

  * The jsonify decorator sets the Content-Type header, but it doesn't
   specify a charset.  Paste freaks out if you do that.  Here's what my
   controller does to work around that problem:

    def _jsonify(self, s):
        This converts the jsonify decorator into a normal method.

                Sometimes a decorator isn't what I need, and treating a 
 function
                decorator as a normal function is funky.

        HACK: The jsonify decorator sets the Content-Type header, but it
        doesn't specify a charset.  Paste freaks out if you do that.

        
        ret = jsonify(lambda: s)()
        response.headers['Content-Type'] = 'application/json; charset=UTF-8'
        return ret

  * I updated my imports in helpers.py per the upgrading docs, but I was a bit
   surprised to find out that stylesheet_link_tag was gone.  It's been renamed
   stylesheet_link.

  * Since I decided to keep my old base.py (since I like the automatic 
 imports),
   I had to manually change how I imported render to
   from pylons.templating import render_mako as render.  The old render
   function is still available, and it's different from the new render
   function.  I'm guessing this isn't a big deal.

  * I had code that was setting response.status_code.  It's documented here
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 that you
   should use status_int.  However, I didn't catch that and there was no
   deprecation warning.  Hence, my code failed silently, or rather it didn't
   fail at all.  It returned a 200 when I was trying to return a 400.  A
   deprecation warning would have been nice.

  * Once I got response.status_code working, it started shoving my HTML
   response into the middle of a big error template instead of just serving
   what I had.  This totally messed with my Web service which counts on
   the sparse HTML error messages I provide.  I hacked around the problem.
   In my action, I wrote:

       request.environ['error_response_is_intentional'] = True

   In error.py's document method, I wrote:

       resp = request.environ['pylons.original_response']
       if request.environ.get('error_response_is_intentional', False):
           page = resp.body
       else:
           content = literal(resp.body) or
 cgi.escape(request.GET.get('message', ''))
           page = error_document_template % \
               dict(prefix=request.environ.get('SCRIPT_NAME', ''),
                    code=cgi.escape(request.GET.get('code',
 str(resp.status_int))),
                    message=content)
       return pag

   This is definitely a hack.  I'm not even sure why this behavior changed.
   If I set request.status_code, and I set the HTML containing the error
   message, it should just leave it alone.

   By the way, why does the code use
   request.environ.get('pylons.original_response') when it soon does
   resp.body?  Why not do a normal dict lookup (i.e. [])?  If you don't have
   that key, you'll get a None, and resp.body will crash anyway.

 Ok, I hope that was helpful.  If you want bugs for any of these, I'm
 happy to submit them.

 Best Regards,
 -jj

This thread kind of died.  I think that some of the above should
result in changes to the upgrading notes, and I think one or two of
them should probably result in code changes.  Should I submit patches,
bugs, etc.?

-jj

-- 
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



challenges while upgrading to 0.9.7

2009-05-22 Thread Shannon -jj Behrens

I have a project in production, and I decided to upgrade my app from
0.9.6.1 to 0.9.7.  I read all the docs related to upgrading.  I
decided to use paster create myapp -t pylons to upgrade my project.
These are the headaches I encountered:

 * Warn people that if they use paster create to upgrade their project, they
   probably don't want to override base.py.  After all, paster create doesn't
   update your controllers, and my controllers depended on the imports in
   base.py.

 * AttributeError: 'module' object has no attribute 'url_for'
   I was using h.url_for in a controller.  It's even mentioned in
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779
   (which is probably a bug).  I didn't find any mention in the upgrading docs
   that this was gone.  I added from routes import url_for to my helpers.py.

 * The jsonify decorator sets the Content-Type header, but it doesn't
   specify a charset.  Paste freaks out if you do that.  Here's what my
   controller does to work around that problem:

def _jsonify(self, s):
This converts the jsonify decorator into a normal method.

Sometimes a decorator isn't what I need, and treating a function
decorator as a normal function is funky.

HACK: The jsonify decorator sets the Content-Type header, but it
doesn't specify a charset.  Paste freaks out if you do that.


ret = jsonify(lambda: s)()
response.headers['Content-Type'] = 'application/json; charset=UTF-8'
return ret

 * I updated my imports in helpers.py per the upgrading docs, but I was a bit
   surprised to find out that stylesheet_link_tag was gone.  It's been renamed
   stylesheet_link.

 * Since I decided to keep my old base.py (since I like the automatic imports),
   I had to manually change how I imported render to
   from pylons.templating import render_mako as render.  The old render
   function is still available, and it's different from the new render
   function.  I'm guessing this isn't a big deal.

 * I had code that was setting response.status_code.  It's documented here
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 that you
   should use status_int.  However, I didn't catch that and there was no
   deprecation warning.  Hence, my code failed silently, or rather it didn't
   fail at all.  It returned a 200 when I was trying to return a 400.  A
   deprecation warning would have been nice.

 * Once I got response.status_code working, it started shoving my HTML
   response into the middle of a big error template instead of just serving
   what I had.  This totally messed with my Web service which counts on
   the sparse HTML error messages I provide.  I hacked around the problem.
   In my action, I wrote:

   request.environ['error_response_is_intentional'] = True

   In error.py's document method, I wrote:

   resp = request.environ['pylons.original_response']
   if request.environ.get('error_response_is_intentional', False):
   page = resp.body
   else:
   content = literal(resp.body) or
cgi.escape(request.GET.get('message', ''))
   page = error_document_template % \
   dict(prefix=request.environ.get('SCRIPT_NAME', ''),
code=cgi.escape(request.GET.get('code',
str(resp.status_int))),
message=content)
   return pag

   This is definitely a hack.  I'm not even sure why this behavior changed.
   If I set request.status_code, and I set the HTML containing the error
   message, it should just leave it alone.

   By the way, why does the code use
   request.environ.get('pylons.original_response') when it soon does
   resp.body?  Why not do a normal dict lookup (i.e. [])?  If you don't have
   that key, you'll get a None, and resp.body will crash anyway.

Ok, I hope that was helpful.  If you want bugs for any of these, I'm
happy to submit them.

Best Regards,
-jj

-- 
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: challenges while upgrading to 0.9.7

2009-05-22 Thread Shannon -jj Behrens

  * Once I got response.status_code working, it started shoving my HTML
    response into the middle of a big error template instead of just serving
    what I had.  This totally messed with my Web service which counts on
    the sparse HTML error messages I provide.  I hacked around the problem.
    In my action, I wrote:

        request.environ['error_response_is_intentional'] = True

    In error.py's document method, I wrote:

        resp = request.environ['pylons.original_response']
        if request.environ.get('error_response_is_intentional', False):
            page = resp.body
        else:
            content = literal(resp.body) or
 cgi.escape(request.GET.get('message', ''))
            page = error_document_template % \
                dict(prefix=request.environ.get('SCRIPT_NAME', ''),
                     code=cgi.escape(request.GET.get('code',
 str(resp.status_int))),
                     message=content)
        return pag

    This is definitely a hack.  I'm not even sure why this behavior changed.
    If I set request.status_code, and I set the HTML containing the error
    message, it should just leave it alone.

 One of the default middlewares is doing this--StatusCodeRedirect. I
 completely removed this from the Pylons project I'm using for web
 services.

 In another project, I have this in certain controllers:

    request.environ['pylons.status_code_redirect'] = True

 I found that by reading the source. If I understand it correctly, it
 disables StatusCodeRedirect for a given request. (It seems to work,
 but the semantics are confusing.)

Yep, that worked like a charm, thanks!

Since this is a change in behavior and it requires a change in code to
get the old behavior back, it probably makes sense to call this out in
the upgrading docs.

Thanks Again,
-jj

-- 
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: challenges while upgrading to 0.9.7

2009-05-22 Thread Shannon -jj Behrens

On Fri, May 22, 2009 at 2:33 AM, Shannon -jj Behrens jji...@gmail.com wrote:
 I have a project in production, and I decided to upgrade my app from
 0.9.6.1 to 0.9.7.  I read all the docs related to upgrading.  I
 decided to use paster create myapp -t pylons to upgrade my project.
 These are the headaches I encountered:

  * Warn people that if they use paster create to upgrade their project, they
   probably don't want to override base.py.  After all, paster create doesn't
   update your controllers, and my controllers depended on the imports in
   base.py.

  * AttributeError: 'module' object has no attribute 'url_for'
   I was using h.url_for in a controller.  It's even mentioned in
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779
   (which is probably a bug).  I didn't find any mention in the upgrading docs
   that this was gone.  I added from routes import url_for to my helpers.py.

  * The jsonify decorator sets the Content-Type header, but it doesn't
   specify a charset.  Paste freaks out if you do that.  Here's what my
   controller does to work around that problem:

    def _jsonify(self, s):
        This converts the jsonify decorator into a normal method.

                Sometimes a decorator isn't what I need, and treating a 
 function
                decorator as a normal function is funky.

        HACK: The jsonify decorator sets the Content-Type header, but it
        doesn't specify a charset.  Paste freaks out if you do that.

        
        ret = jsonify(lambda: s)()
        response.headers['Content-Type'] = 'application/json; charset=UTF-8'
        return ret

  * I updated my imports in helpers.py per the upgrading docs, but I was a bit
   surprised to find out that stylesheet_link_tag was gone.  It's been renamed
   stylesheet_link.

  * Since I decided to keep my old base.py (since I like the automatic 
 imports),
   I had to manually change how I imported render to
   from pylons.templating import render_mako as render.  The old render
   function is still available, and it's different from the new render
   function.  I'm guessing this isn't a big deal.

  * I had code that was setting response.status_code.  It's documented here
   http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 that you
   should use status_int.  However, I didn't catch that and there was no
   deprecation warning.  Hence, my code failed silently, or rather it didn't
   fail at all.  It returned a 200 when I was trying to return a 400.  A
   deprecation warning would have been nice.

  * Once I got response.status_code working, it started shoving my HTML
   response into the middle of a big error template instead of just serving
   what I had.  This totally messed with my Web service which counts on
   the sparse HTML error messages I provide.  I hacked around the problem.
   In my action, I wrote:

       request.environ['error_response_is_intentional'] = True

   In error.py's document method, I wrote:

       resp = request.environ['pylons.original_response']
       if request.environ.get('error_response_is_intentional', False):
           page = resp.body
       else:
           content = literal(resp.body) or
 cgi.escape(request.GET.get('message', ''))
           page = error_document_template % \
               dict(prefix=request.environ.get('SCRIPT_NAME', ''),
                    code=cgi.escape(request.GET.get('code',
 str(resp.status_int))),
                    message=content)
       return pag

   This is definitely a hack.  I'm not even sure why this behavior changed.
   If I set request.status_code, and I set the HTML containing the error
   message, it should just leave it alone.

   By the way, why does the code use
   request.environ.get('pylons.original_response') when it soon does
   resp.body?  Why not do a normal dict lookup (i.e. [])?  If you don't have
   that key, you'll get a None, and resp.body will crash anyway.

 Ok, I hope that was helpful.  If you want bugs for any of these, I'm
 happy to submit them.

One more:

 * I don't use the Pylons way of running nose.  I test my Pylons app as just
   one of the packages in my project.  Hence, I have a Makefile
   with nosetests --with-doctest  $(OUR_PACKAGES).  I had to add
   --with-pylons mywebapp/test.ini.  I kept getting
   ERROR: Failure: KeyError ('__file__') when trying to run my
tests, and a bunch
   of my other tests failed because they couldn't get an expected value from the
   .ini file.

   This is hinted at in
http://pylonshq.com/articles/archives/2009/2/pylons_097_released,
   but perhaps needs to be called out more explicitly for those of us who run
   nosetests manually without going through setuptools, etc.

Thanks!
-jj

-- 
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons

logging setup

2009-02-24 Thread Shannon -jj Behrens
It's weird that the default setup in development.ini is:

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

I used log.warn in my controller and it didn't go to stderr.  I changed
level to INFO so I can see the logging message.

Best Regards,
-jj

-- 
In this life we cannot do great things. We can only do small things with
great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: SMTPHandler not working

2009-02-18 Thread Shannon -jj Behrens

Check out this blog post:
http://jjinux.blogspot.com/2009/02/python-logging-to-email-in-pylons.html

If you have any comments, leave them on my blog.  I'm having a hard
time keeping up with this list ;)

-jj

On Wed, Dec 17, 2008 at 2:16 AM, Pavel Skvazh pavel.skv...@gmail.com wrote:

 Trying to use SMTPHandler for logging with Pylons trunk version.

 [handler_smtp]
 class = SMTPHandler
 args = ('localhost','err...@my.com', ...', '...')
 formatter = generic

  File D:\Python25\Scripts\paster-script.py, line 8, in module
load_entry_point('pastescript==1.7.3', 'console_scripts', 'paster')
 ()
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\c
 ommand.py, line 84, in run
invoke(command, command_name, options, args[1:])
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\c
 ommand.py, line 123, in invoke
exit_code = runner.run(args)
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\c
 ommand.py, line 218, in run
result = self.command()
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\s
 erve.py, line 271, in command
self.logging_file_config(log_fn)
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\c
 ommand.py, line 757, in logging_file_config
fileConfig(config_file)
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\u
 til\logging_config.py, line 85, in fileConfig
handlers = _install_handlers(cp, formatters)
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\u
 til\logging_config.py, line 155, in _install_handlers
klass = _resolve(klass)
  File d:\python25\lib\site-packages\pastescript-1.7.3-py2.5.egg\paste
 \script\u
 til\logging_config.py, line 95, in _resolve
found = __import__(used)
 ImportError: No module named SMTPHandler
 Exception in thread Thread-1 (most likely raised during interpreter
 shutdown):
 Traceback (most recent call last):
  File D:\Python25\lib\threading.py, line 460, in __bootstrap
  File D:\Python25\lib\threading.py, line 440, in run
  File d:\python25\lib\site-packages\paste-1.7.2-py2.5.egg\paste
 \reloader.py,
 line 86, in periodic_reload
 type 'exceptions.AttributeError': 'NoneType' object has no attribute
 '_exit'

 




-- 
In this life we cannot do great things. We can only do small things
with great love. -- Mother Teresa
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: supervisor questions

2008-07-09 Thread Shannon -jj Behrens

On Mon, Jul 7, 2008 at 4:37 PM, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 Hi,

 I'm looking at 
 http://wiki.pylonshq.com/display/pylonscookbook/Monitor+Pylons+application+with+supervisord.
  I have a few questions:

 1. Why does it use a manually created server.py instead of using
 paster like normal?

 2. Does anyone have an rc script to start supervisor under Ubuntu?

 3. Is anyone doing any fancy log rotation or are the defaults reasonable?

I decided to use runit.  I blogged about how and why here:

http://jjinux.blogspot.com/2008/07/linux-running-paster-under-runit-on.html

I'm not trying to dissuade anyone else from using Supervisor.

Best Regards,
-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: best way to get user's IP address in pylons?

2008-07-09 Thread Shannon -jj Behrens

On Mon, Jul 7, 2008 at 6:18 PM, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 Ugh, looking at request.environ, Varnish is giving me
 HTTP_X_FORWARDED_FOR.  Looking at my old Aquarium code, it respected
 X_FORWARDED_HOST.  Looking at Paste's proxy middleware, I see that it
 looks for X-Forwarded-Server.  Gees, am I confused!  Can someone lend
 me a clue?

It turned out that I just needed to follow the Cookbook recipe a
little bit more closely:
http://wiki.pylonshq.com/display/pylonscookbook/Running+Pylons+with+NGINX

The trick is configuring Nginx with:

proxy_set_headerHost $host;
proxy_set_headerX-Real-IP $remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;

Once you do this, you don't even need to use Paste's proxy middleware.
 Nginx itself will setup the Host header correctly.

I'm still not sure why that recipe configures so many buffer sizes.
When I read things like that, it makes me wonder why they're necessary
and whether Nginx's own defaults are actually broken.  I also wonder
if those settings are even appropriate for my situation.

Happy Hacking!
-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



supervisor questions

2008-07-07 Thread Shannon -jj Behrens

Hi,

I'm looking at 
http://wiki.pylonshq.com/display/pylonscookbook/Monitor+Pylons+application+with+supervisord.
 I have a few questions:

1. Why does it use a manually created server.py instead of using
paster like normal?

2. Does anyone have an rc script to start supervisor under Ubuntu?

3. Is anyone doing any fancy log rotation or are the defaults reasonable?

Thanks,
-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: A new SQLAlchemy migration toolkit - miruku 0.1a3 has been released

2008-07-07 Thread Shannon -jj Behrens

On Thu, Jul 3, 2008 at 6:59 PM, Olli Wang [EMAIL PROTECTED] wrote:

 On Jul 4, 9:42 am, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 How is it possible to not require an upgrade script?  What happens if
 I'm changing an email field into two fields, one for the username and
 one for the server?

 -jj

 --
 It's a walled garden, but the flowers sure are 
 lovely!http://jjinux.blogspot.com/

 What miruku does is finding the difference between original schema and
 modified schema,  then upgrade the original schema to the modified
 schema (add/drop columns/tables, etc).
 In your question, it seems you just need to add a new email column
 which may be located in the same or different table. It doesn't
 matter, just change the model schema code by add a new email column
 and run miruku upgrade command. Then you will have two email field.
 However, currently miruku only support add/drop tables/columns/index.
 So there is no way to copy the email value to the new field
 automatically. But I think it's a good idea to work it our in the
 future. :)

I think it's an 80/20 thing.  You got 80% of what everyone needs by
writing 20% of the code, and, as usual, I'm obsessed with the
remaining 20% ;)

Happy Hacking!
-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: mod_wsgi does not check for changed files?

2008-06-28 Thread Shannon -jj Behrens

On Fri, Jun 27, 2008 at 12:53 PM, webwurst [EMAIL PROTECTED] wrote:
 Hi!

 If i start a pylons project with paster i can add the parameter --
 relaod, so changes to the source code are reflected directly. But i'm
 using mod_wsdi now and i have to restard apache if i want changes in a
 python file to take effect!

 Is there a way that changed files are checked with mod_wsgi?

In the old days before mod_wsgi, I would just set my process request
limit to 1 so that each request would get a new Python interpreter.
Of course, this was for development only ;)

-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Testing with the session object

2008-06-28 Thread Shannon -jj Behrens

On Fri, Jun 27, 2008 at 6:33 AM, Marin [EMAIL PROTECTED] wrote:

 I have this controller:

 class HeplController(BaseController):

def index(self):
del session['user']
session.save()
return 'OK'

 And I want to test if it works correctly with this test:

 class TestHeplController(TestController):

def test_index(self):
#session['user'] = 'foo' --- does not work
response = self.app.get(url_for(controller='hepl'))
assert 'user' not in response.session

 How can I put something in the session object before I call
 self.app.get(...)?

You're trying to use the session from outside the context of a Web
request.  At that point in the code, in a sense, Pylons isn't even
fired up.  Here are two approaches that might work:

 * Use one action to put something into the session and then another
to make use of the session.  It's a work flow.

 * If I remember correctly, there's a way to shove stuff into the
environ that will be passed to the request.  Shove in a callback named
setup_session_for_tests that gets called by the parent class of the
controller.  You can also mess around with the environ after the
request.  There's a key called paste testing variables or something
like that.

Happy Hacking!
-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: com to co.uk with url_for

2008-06-28 Thread Shannon -jj Behrens

Pass qualified=True to url_for.

-jj

On Wed, Jun 25, 2008 at 7:26 AM, Nico Nicolic [EMAIL PROTECTED] wrote:

 Ok, I've created my own solution with regular expression. But the
 problem is, when I'm trying to get the existing URL with url_for(),
 it's just returns the relative url: /, but I need to get the full
 url, like http://mydomain.com. How can I get this url?

 On Jun 23, 2:25 pm, Nico Nicolic [EMAIL PROTECTED] wrote:
 Hi,

 I know that it's possible to generate links to the subdomains with
 using url_for function. Ex: url_for(sub_domain='mysubdomain' ) etc.
 But now I need to link to my domain names like mydomain.co.uk/com.au/
 de... Is there any solution for this or do I need to create my own?

 Thanks

 




-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons equivalent of cherrypy's serve_file?

2008-06-25 Thread Shannon -jj Behrens

On Tue, Jun 24, 2008 at 7:41 PM, Chris [EMAIL PROTECTED] wrote:
 Is there a Pylons equivalent of CherryPy's serve_file ?
 I'm trying to allow file download for files that are not in the
 'public' directory

 In cherry py, it'd go something like this:
 from cherrypy.lib.static import serve_file
 class Root:
@cherrypy.expose
def download(self, name):
return serve_file(os.path.join(download_dir, name),
 content_type='text/plain')

 Many thanks.

You might need to think about browser caching.  If-Modified-Since and
If-Modified aren't that hard to do manually.  I've done them before
when I was generating JavaScript dynamically so that the browser
wouldn't have to redownload the JavaScript on every page hit.

-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: How are c/h/etc provided to templates?

2008-06-24 Thread Shannon -jj Behrens

On Tue, Jun 24, 2008 at 7:25 AM, Jonathan Vanasco [EMAIL PROTECTED] wrote:
 I'm trying to make two other objects available to all templates.

 I'm wondering what the best practice would be.

 Looking at pylons.templating, I'm honestly a bit confused about what
 is going on.

 ( and if you're wondering: object1 is a version of pylons.c that is
 for the underlying framework we built on pylons ; object2 is a second
 version that will return the value in pylons if it exists, else
 default to the object1 value )

I like to setup things like that in the parent class controller.  See
app/lib/base.py.

-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: url_for for static resources

2008-06-21 Thread Shannon -jj Behrens

On Sat, Jun 21, 2008 at 7:53 AM, Jonathan Vanasco [EMAIL PROTECTED] wrote:
 i had a similar situation -- i wanted to change url_for's output on
 people who have a 'preview' cookie and those who don't

 i basically did this

 def url_for_custom( url ):
rval = url_for(url)
if logic_test():
rval = regex or stringsub or both
return rval

 then quickly did a find/replace on the entire pylons app with url_for -
 url_for_custom

 its ridiculously not messy, simple, and gets the job done.

url_for comes from webhelpers.  Can't you just hijack it there and
reuse the same name?

-jj

-- 
It's a walled garden, but the flowers sure are lovely!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Reddit open sources their site pylons implementation

2008-06-19 Thread Shannon -jj Behrens

On Wed, Jun 18, 2008 at 8:03 AM, aaaron [EMAIL PROTECTED] wrote:
 Announcement:

 http://blog.reddit.com/2008/06/reddit-goes-open-source.html

 Trac:

 http://code.reddit.com/

That video was awesome ;)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: '+' in URL not getting stripped away like '%20'

2008-06-19 Thread Shannon -jj Behrens

If you put a URL into some HTML, you should HTML escape it.  Yes, this
is strange.  I wrote about it here:

http://jjinux.blogspot.com/2006/03/html-escaping-s-in-urls-in-html.html

Best Regards,
-jj

On Thu, Jun 19, 2008 at 11:48 AM, Tom [EMAIL PROTECTED] wrote:
 Just wanted to update anyone who comes across this and needs a (bad)
 solution. I managed to get this to work using something quite ugly.
 Instead of:

 redirect_to(controller='page', action='index', title=title)

 I used:

 redirect_to('/page/index/'+str(title))

 Getting rid of the str() in the second one or adding str() to the
 first one did not work.

 On Jun 19, 1:28 pm, Tom [EMAIL PROTECTED] wrote:
 I've come across an issue involving the use of '+' and '%20' for
 representing spaces in a URL.

 Many apps treat the plus sign and the %20 code the same, however
 pylons does not.  Lets say you have a def which takes in one argument,
 lets call it 'title', sets it as c.title, and a mako template that
 prints c.title.

 If your title string is foo+bar, mako renders the string foo+bar,
 whereas if your title string is foo%20bar, it renders foo bar.
 Generally, this isn't much of an issue, as one can make URLs that have
 %20 instead of +, however the redirect_to() function in pylons changes
 spaces to + and not %20.

 So my question is, is there a way to change how redirect_to encodes
 strings? I've tried changing spaces to %20 prior to passing it to
 redirect_to, but all that happens is that the % sign gets encoded
 itself and %20 shows up as part of the title.

 Thanks.
 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: '+' in URL not getting stripped away like '%20'

2008-06-19 Thread Shannon -jj Behrens

Hmm, upon rereading your post, I'm not sure if the two things are
connected.  Sorry.

-jj

On Thu, Jun 19, 2008 at 1:57 PM, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 If you put a URL into some HTML, you should HTML escape it.  Yes, this
 is strange.  I wrote about it here:

 http://jjinux.blogspot.com/2006/03/html-escaping-s-in-urls-in-html.html

 Best Regards,
 -jj

 On Thu, Jun 19, 2008 at 11:48 AM, Tom [EMAIL PROTECTED] wrote:
 Just wanted to update anyone who comes across this and needs a (bad)
 solution. I managed to get this to work using something quite ugly.
 Instead of:

 redirect_to(controller='page', action='index', title=title)

 I used:

 redirect_to('/page/index/'+str(title))

 Getting rid of the str() in the second one or adding str() to the
 first one did not work.

 On Jun 19, 1:28 pm, Tom [EMAIL PROTECTED] wrote:
 I've come across an issue involving the use of '+' and '%20' for
 representing spaces in a URL.

 Many apps treat the plus sign and the %20 code the same, however
 pylons does not.  Lets say you have a def which takes in one argument,
 lets call it 'title', sets it as c.title, and a mako template that
 prints c.title.

 If your title string is foo+bar, mako renders the string foo+bar,
 whereas if your title string is foo%20bar, it renders foo bar.
 Generally, this isn't much of an issue, as one can make URLs that have
 %20 instead of +, however the redirect_to() function in pylons changes
 spaces to + and not %20.

 So my question is, is there a way to change how redirect_to encodes
 strings? I've tried changing spaces to %20 prior to passing it to
 redirect_to, but all that happens is that the % sign gets encoded
 itself and %20 shows up as part of the title.

 Thanks.
 




 --
 I, for one, welcome our new Facebook overlords!
 http://jjinux.blogspot.com/




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: jsonp support

2008-06-19 Thread Shannon -jj Behrens

I understand what you mean.

I return my errors in JSON.  I think that makes the user's life easier.

-jj

On Thu, Jun 19, 2008 at 3:25 PM, Jonathan Vanasco [EMAIL PROTECTED] wrote:
 this thread had me thinking...

 it would be really neat if there were a way to cancel out the jsonify
 decorator in a function

 ie:

 @jsonify
 def index(self):
   rVal= { 'status': 'error' }
   self.jsonify_cancel()
   return rVal

 i can't remember why i wanted to do this, but i had a good reason to
 the other day!
 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: jsonp support

2008-06-19 Thread Shannon -jj Behrens

On Thu, Jun 19, 2008 at 3:29 PM, Ian Bicking [EMAIL PROTECTED] wrote:
 Maybe something like this:

 class HTTP_OK(HTTPException):
   code = 200
   message = 'OK'

 raise HTTP_OK('some message')

 A little weird.  But a good way to break out of the decorators.

Hey Ian,

I've needed that before.  I remember that the situation was pretty
strange.  I ended up coding something just like that.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: jsonp support

2008-06-17 Thread Shannon -jj Behrens

On Tue, Jun 17, 2008 at 2:55 PM, Ian Bicking [EMAIL PROTECTED] wrote:
 Shannon -jj Behrens wrote:
 I'm using the jsonify decorator.  It'd be nice if that decorator were
 updated to *automatically* support the jsonp parameter
 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.
 Hence, if I request a URL like
 http://localhost:5000/api/service?jsonp=foo, and jsonify is used, it
 should automatically wrap the JSON in foo().

 Isn't JSONP a security concern if you aren't exposing something intended
 to be public?  That is, you can use JSONP to read data using the
 browser's credentials, which is sometimes okay and sometimes not.  So
 optionally turning it on is nice, but always turning it on is dangerous.

I can't comment on that.  My service is a public service.  Perhaps you
can explain what you mean in more detail.  Bob talks about security a
bit on his blog post:
http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: jsonp support

2008-06-17 Thread Shannon -jj Behrens

On Tue, Jun 17, 2008 at 3:21 PM, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 On Tue, Jun 17, 2008 at 2:55 PM, Ian Bicking [EMAIL PROTECTED] wrote:
 Shannon -jj Behrens wrote:
 I'm using the jsonify decorator.  It'd be nice if that decorator were
 updated to *automatically* support the jsonp parameter
 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.
 Hence, if I request a URL like
 http://localhost:5000/api/service?jsonp=foo, and jsonify is used, it
 should automatically wrap the JSON in foo().

 Isn't JSONP a security concern if you aren't exposing something intended
 to be public?  That is, you can use JSONP to read data using the
 browser's credentials, which is sometimes okay and sometimes not.  So
 optionally turning it on is nice, but always turning it on is dangerous.

 I can't comment on that.  My service is a public service.  Perhaps you
 can explain what you mean in more detail.  Bob talks about security a
 bit on his blog post:
 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.

The JavaScript does have to *trust* the remote server.  Of course, if
it doesn't, it shouldn't be using script tags to pull stuff from that
remote server.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: jsonp support

2008-06-17 Thread Shannon -jj Behrens

On Tue, Jun 17, 2008 at 3:25 PM, Ian Bicking [EMAIL PROTECTED] wrote:

 Shannon -jj Behrens wrote:
 On Tue, Jun 17, 2008 at 2:55 PM, Ian Bicking [EMAIL PROTECTED] wrote:
 Shannon -jj Behrens wrote:
 I'm using the jsonify decorator.  It'd be nice if that decorator were
 updated to *automatically* support the jsonp parameter
 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.
 Hence, if I request a URL like
 http://localhost:5000/api/service?jsonp=foo, and jsonify is used, it
 should automatically wrap the JSON in foo().
 Isn't JSONP a security concern if you aren't exposing something intended
 to be public?  That is, you can use JSONP to read data using the
 browser's credentials, which is sometimes okay and sometimes not.  So
 optionally turning it on is nice, but always turning it on is dangerous.

 I can't comment on that.  My service is a public service.  Perhaps you
 can explain what you mean in more detail.  Bob talks about security a
 bit on his blog post:
 http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/.

 Let's say I have a JSON method that returns your list of friends.
 That's private, and the method is restricted based on authentication.
 But any random website could include this:

 script
 src=http://somesocialnetwork.org/api/friends?jsonp=readFriends;/script

 and then it would be able to read your private list of friends if you
 had logged into somesocialnetwork.org.

 Simply requiring people to explicitly turn on jsonp support, with a
 warning that only public data should be exposed that way, would address
 that issue.

Good point.  So you're saying that if you don't use jsonp, then when
the attacker causes the victim to view a script tag that pulls stuff
down via JSON, since there's no function to receive the JSON, it
gets pulled down, but immediately disappears, right?  What a strange
defense mechanism.  XSRF is a pain, eh?

I'm okay with needing to turn on jsonp support.  If there were a jsonp
flag for the jsonify decorator, then you could enable it in as few
places as possible.

Best Regards,
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: WebHelpers-dev change: select() option order

2008-06-17 Thread Shannon -jj Behrens

On Tue, Jun 17, 2008 at 2:52 PM, Mike Orr [EMAIL PROTECTED] wrote:
 The option order in webhelpers.html.tags.select() has changed from
 [(label, value)] to [(value, label)].  This matches most real-world
 lists including dict.items() where the dict is {id : label}.  It's the
 opposite of the old rails helper options_for_select(), however.

 There are tradeoffs both ways.  Now to display lables alphabetically
 you have to do:
sorted(my_options, key=lambda x: x[1])

 However, I was finding that the other order causes way too many:
[(x[1], x[0]) for x in some_list]

I fear that this is too likely to cause weird bugs for people.
Perhaps you should create a new method name.  You can have the old one
defined in terms of the new, and then deprecate it.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: WebHelpers-dev change: select() option order

2008-06-17 Thread Shannon -jj Behrens

On Tue, Jun 17, 2008 at 7:48 PM, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 On Tue, Jun 17, 2008 at 2:52 PM, Mike Orr [EMAIL PROTECTED] wrote:
 The option order in webhelpers.html.tags.select() has changed from
 [(label, value)] to [(value, label)].  This matches most real-world
 lists including dict.items() where the dict is {id : label}.  It's the
 opposite of the old rails helper options_for_select(), however.

 There are tradeoffs both ways.  Now to display lables alphabetically
 you have to do:
sorted(my_options, key=lambda x: x[1])

 However, I was finding that the other order causes way too many:
[(x[1], x[0]) for x in some_list]

 I fear that this is too likely to cause weird bugs for people.
 Perhaps you should create a new method name.  You can have the old one
 defined in terms of the new, and then deprecate it.

Perhaps I misread your email.  You're creating a new API, not
refactoring an existing API, right?  If so, then please disregard my
comment.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: best practices for static resources

2008-06-17 Thread Shannon -jj Behrens

On Mon, Jun 16, 2008 at 2:37 PM, Cliff Wells [EMAIL PROTECTED] wrote:
 On Mon, 2008-06-16 at 14:26 -0700, Cliff Wells wrote:
 On Mon, 2008-06-16 at 13:03 +0200, Wichert Akkerman wrote:
  I am trying to figure out what the best practices for dealing with
  static resources such as CSS, Javascript and images are. With a
  default pylons setup every request goes through two StaticURLParser
  instances and files returned by them do not get any caching headers.
  This is very practical for development but not ideal for a deployment
  For a deployment it would be nice to be able to serve static resources
  from apache or nginx.
 
  How do others do that? Do you use url_for to generate a URL for those
  static resources and have that return a non-paster/pylons URL for
  deployment environments and use the StaticURLParsers when running in
  in development mode? If so, how did you set that up?

 I usually just setup Nginx to handle whatever location my static content
 is at.  It doesn't matter if Routes is setup to handle that location as
 the request never reaches Pylons.

 Here's an example:

 server {
server_name *.domain.com;
listen  1.2.3.4:80;

location /public/ {
root/var/www/myapp;
expires 30d;
}

location / {
proxy_pass http://127.0.0.1:8000$request_uri;
include/etc/nginx/proxy.conf; # common settings for proxying
}
 }

 In this case, any request for, say /public/css/style.css would map to 
 /var/www/myapp/public/css/style.css.

 Regards,
 Cliff

I let Nginx handle the URL if such a file exists.  Otherwise, I let
Pylons have a shot at it:

...
server {
listen   80;
server_name  localhost;

location / {
# Let Nginx handle static content, but proxy to paster for all the
# dynamic content.
root/.../wwwaiter/wwwaiter/public;
if (!-e $request_filename) {
proxy_pass   http://127.0.0.1:5000;
}
}

That way I don't have to include public in my URLs ;-)

(Of course, including public in the URL would probably make life
easier if I needed to move to something more complicated like a CDN.)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Adding content-length in all responses

2008-06-17 Thread Shannon -jj Behrens

On Mon, Jun 16, 2008 at 4:11 PM, Agustín (Cucho) Villena
[EMAIL PROTECTED] wrote:
 Hi!

 At work we need to add the content-length header in all our
 responses, but we don't want to hack any method in our controllers to
 do that.

 Is there any way to factor out this behaviour in a single place?

Can you use Apache or Nginx to do that for you?

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons-based JSON-RPC service?

2008-06-17 Thread Shannon -jj Behrens

On Sun, Jun 15, 2008 at 1:12 PM, KJ [EMAIL PROTECTED] wrote:
 Would Pylons be a good choice for implementing a JSON-RPC-based web
 service?

 If yes, can someone point me to a good example?  (Actually, I'd be
 interested in seeing examples of any Pylons-based web service, even if
 it doesn't use JSON.)

 If not what other framework would more suited for this task?

I decided to implement a RESTful, JSON API instead of using JSON-RPC.
That means:

* All the parameters are put in GET and POST parameters.
* I shove as much stuff in the URL as makes sense.
* I use HTTP response codes to indicate errors.
* I put whatever the heck I want in the JSON response.
* I use a JSON response for both successes and many failures.

It's not as brain-dead simple as XML-RPC use to be, but it's working for me.

Reading the Wikipedia page on REST was helpful for me.

Best Regards,
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: WebHelpers with Genshi do not work

2008-06-14 Thread Shannon -jj Behrens

I wonder if the b has to be escaped, like lt;bgt;.

-jj

On Sat, Jun 14, 2008 at 12:11 PM, webwurst [EMAIL PROTECTED] wrote:

 Hi!

 I just tried this example similar to that from
 http://genshi.edgewall.org/wiki/GenshiRecipes/PylonsWithGenshi#TheHardWay

 !DOCTYPE html
PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
  xmlns:py=http://genshi.edgewall.org/;
  xmlns:xi=http://www.w3.org/2001/XInclude;
  py:strip=
  head py:match=head
titleThe Title/title
  /head
  body
 h1hello/h1
 ${HTML('bFoo/b')}
  /body
 /html

 And i get the following error message:
 class 'genshi.template.base.TemplateSyntaxError': invalid syntax (/
 home/webwurst/Devel/pylons/gettingstarted/helloworld/helloworld/
 templates/formtest.html, line 13)

 If i try ${HTML('Foo')} then it works..


 What is wrong with the first example?

 Cheers,
 Tobias Bradtke

 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Difference between controllers and views?

2008-06-13 Thread Shannon -jj Behrens

Yes.  You could hack around that, but it'd probably be painful.  What
I'm saying is that:

a) Using classes is a good idea.

b) Pylons doesn't force you to code a certain way within those
classes.  You can move as much or as little as you want into the
models or other libraries.

Best Regards,
-jj

On Fri, Jun 13, 2008 at 6:53 AM, askel [EMAIL PROTECTED] wrote:
 -jj,

 Isn't that enforced by Routes that controllers must be classes? I
 remember some discussion about possibility of using any other
 dispatching library/method in Pylons. It was something about new WSGI
 environment key wsgiorg.routing_args. I might be completely wrong on
 that though.

 Cheers
 Alexander

 On Jun 12, 9:59 pm, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 On Thu, Jun 12, 2008 at 10:05 AM, rcs_comp [EMAIL PROTECTED] wrote:
  On Jun 11, 4:10 pm, Karlo Lozovina [EMAIL PROTECTED] wrote:
  What's the practical difference between controller based approach and
  views based one? Eg. Django views, and controllers in Pylons? It
  doesn't seem that much different, so why not make all controller
  actions regular functions, instead of class methods? What's the gain
  in this controller approach, if any? :)

  Thanks...

  I differ a bit from the opinions above.  I like to think of a web
  request as asking show me something.  Therefore, IMO, it makes sense
  to map a web request to a view.  The view (a Python class) then
  knows how to use actions (a Python class) to do something, the
  actions know how to use the model to get work done.  The view then
  renders a response in an appropriate format (HTML, JSON, etc.) using
  any helpers necessary (i.e. templates).  The view does not have to
  render using a template though.

  I had a diagram of this at one point, but can't get the darn thing to
  open right now.  If anyone is interested in seeing a diagram let me
  know and I will try to get it working and post one.

 What you are describing is closer to the Rails philosophy.  They're
 big on pushing stuff into models, even validation.  I've done it that
 way, and that works too.

 I think of it like a pie.  You can slice the pie in many ways.  Slice
 it however you like.

 That's one thing I like about Pylons.  It does make you use a class
 with methods, but it doesn't force you too much beyond that.  If you
 want to do something strange like put all your logic in models and
 then use string interpolation within your controllers you can.
 Whatever floats your boat ;)

 Happy Hacking!
 -jj

 --
 I, for one, welcome our new Facebook overlords!http://jjinux.blogspot.com/-
 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Exception email reporting in production

2008-06-13 Thread Shannon -jj Behrens

Ah, yes.  Sorry, I should have spotted that.  Email systems tend to
drop email when the destination and the origin address are the same.

-jj

On Fri, Jun 13, 2008 at 2:53 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 Cheers! It turns out my email provider was silently ignoring all those
 mails and just changing the address did the trick.
 thanks
 Ben

 On 13 Jun, 03:01, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 On Thu, Jun 12, 2008 at 3:48 AM, [EMAIL PROTECTED]



 [EMAIL PROTECTED] wrote:

  Hi, I'm having trouble getting pylons to report errors via email where
  debug = false - basically nothing ever turns up.

  In production.ini there are some lines like:

  email_to = [EMAIL PROTECTED]
  smtp_server = localhost
  error_email_from = [EMAIL PROTECTED]

  I can manually set up smtplib and send emails from localhost via
  controllers without a problem so I'm a bit mystified why this is
  failing. No errors appear on the console either.

  On my development site which does not have a mail server, setting
  debug to false and causing an exception dumps some output to the
  console to do with smtplib failing:

  Additionally an error occurred while sending the
  lt;paste.exceptions.reporter.EmailReporter object...

  File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
  python2.5/smtplib.py, line 310, in connect
 raise socket.error, msg
  error: (49, Can't assign requested address)

  so I'm doubly confused why at least something isn't appearing
  anywhere.

  Any hints as to where to start looking?

 If I were in your shoes, I'd try a few things:

 * Try using smtplib from within a controller.  Does it work?
 * Try using pdb to debug your problem, per my instructions 
 here:http://jjinux.blogspot.com/2007/08/python-coding-in-debugger-for-begi...

 Happy Hacking!
 -jj

 --
 I, for one, welcome our new Facebook overlords!http://jjinux.blogspot.com/
 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Bulk inserts

2008-06-12 Thread Shannon -jj Behrens

On Wed, Jun 11, 2008 at 7:20 PM, Contact 42 [EMAIL PROTECTED] wrote:
 Jonathan Vanasco wrote:
 write to a .txt log in some sort of standardized format , when it hits
 10k lines run a batch query
 what happens if an insert fails ?

It continues with the rest of the batch.  It'll tell you at the end
how many succeeded and how many failed.  You can read the MySQL
documentation to figure out how to look up the error messages.  My
schema is setup so that I don't get failures unless something really
awful happens.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons memory leak

2008-06-12 Thread Shannon -jj Behrens

On Wed, Jun 11, 2008 at 10:28 PM, zepolen [EMAIL PROTECTED] wrote:
 I'm running pylons with paster in daemon mode. At startup the paster
 process is using 10% (100mb) memory.

 Paster is serving about 500k requests per day, 350k are pages, 150k
 are ajax requests. Static files (an extra 800k requests) are being
 served directly with nginx which also acts as the revproxy for paster.

 When using CherryPy as the server, within 4-5 hours the paster process
 reaches 90% memory usage and then dies.

 Paste#http takes longer, about a couple days, I suppose as it recycles
 threads every 100 requests, but it too leaks memory.

 No in-memory caches are being used and the only modules that use c
 extensions are psycopg2 and PIL.

 The global (g) is not being used at all.

 What can I do to find the problem?

I've had some luck in the past finding problems using the gc module.
You might want to google for solutions to this problem since it's
something most Python programmers eventually run across.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Truncating an html string safely

2008-06-12 Thread Shannon -jj Behrens

On Sat, Jun 7, 2008 at 7:24 AM, Matt Feifarek [EMAIL PROTECTED] wrote:
 Oops; replied from the wrong address.

 -- Forwarded message --

 On Thu, Jun 5, 2008 at 2:36 PM, Ian Bicking [EMAIL PROTECTED] wrote:

 Well... it's hard to truncate exactly, as there's all that annoying
 nesting stuff.  An untested attempt with lxml:

 Exactly. Thanks for the lead.

 I'm not sure I'm up to the challenge, but if I do get it working, I'll get
 it back to you, in case it's good enough to be added to lxml (or whatever).

 Mike:
 Seems like if we have the truncate function in webhelpers, a truncate that
 handles html would be wise... since we're, err, making html, usually, with
 Pylons.

 Since the Django code doesn't seem to depend on anything (but some Django
 cruft, which seems to be frosting really) MAYBE it would be better to start
 with.

 But I'll poke around a bit today.

It would be fun to write a SAX handler that permits all tags, and
counts all characters.  It would stop permitting additional characters
once it reached a certain limit.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: DistributionNotFound: decorator problem using PyISAPIe

2008-06-12 Thread Shannon -jj Behrens

On Wed, Jun 4, 2008 at 3:12 PM, rcs_comp [EMAIL PROTECTED] wrote:
 I am trying to get Paste running using the PyISAPIe WSGI server on
 IIS.  However, I am getting this error and I can't figure out why:

 The same application succesfully runs with the paste HTTP server.

 Traceback (most recent call last):
  File C:\Python25\lib\site-packages\Http\Isapi.py, line 128, in
 Request
imp.load_source(Name, Env.APPL_PHYSICAL_PATH +
 '\pyisapie_default.py').Request
  File D:\websites\pylonshw\python\\pyisapie_default.py, line 7, in
pylonsapp = loadapp('config:' + appdir + '/development.ini')
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 193, in loadapp
return loadobj(APP, uri, name=name, **kw)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 213, in loadobj
global_conf=global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 237, in loadcontext
global_conf=global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 267, in _loadconfig
return loader.get_context(object_type, name, global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 393, in get_context
section)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 415, in _context_from_use
object_type, name=use, global_conf=global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 345, in get_context
global_conf=global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 237, in loadcontext
global_conf=global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 274, in _loadegg
return loader.get_context(object_type, name, global_conf)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 542, in get_context
object_type, name=name)
  File C:\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg\paste
 \deploy\loadwsgi.py, line 562, in find_egg_entry_point
pkg_resources.require(self.spec)
  File build/bdist.linux-i686/egg/pkg_resources.py, line 626, in
 require
  File build/bdist.linux-i686/egg/pkg_resources.py, line 524, in
 resolve
 pkg_resources.DistributionNotFound: decorator=2.1.0

Are there multiple versions of Python in the mix, and if so, is one of
them missing the decorator egg?

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Exception email reporting in production

2008-06-12 Thread Shannon -jj Behrens

On Thu, Jun 12, 2008 at 3:48 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 Hi, I'm having trouble getting pylons to report errors via email where
 debug = false - basically nothing ever turns up.

 In production.ini there are some lines like:

 email_to = [EMAIL PROTECTED]
 smtp_server = localhost
 error_email_from = [EMAIL PROTECTED]

 I can manually set up smtplib and send emails from localhost via
 controllers without a problem so I'm a bit mystified why this is
 failing. No errors appear on the console either.

 On my development site which does not have a mail server, setting
 debug to false and causing an exception dumps some output to the
 console to do with smtplib failing:

 Additionally an error occurred while sending the
 lt;paste.exceptions.reporter.EmailReporter object...

 File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/
 python2.5/smtplib.py, line 310, in connect
raise socket.error, msg
 error: (49, Can't assign requested address)

 so I'm doubly confused why at least something isn't appearing
 anywhere.

 Any hints as to where to start looking?

If I were in your shoes, I'd try a few things:

* Try using smtplib from within a controller.  Does it work?
* Try using pdb to debug your problem, per my instructions here:
http://jjinux.blogspot.com/2007/08/python-coding-in-debugger-for-beginners.html

Happy Hacking!
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Bulk inserts

2008-06-11 Thread Shannon -jj Behrens

Beware of multiple threads and/or processes writing to the file at the
same time.  It may make sense to use a mutex.

I agree with the earlier recommendations to use mysql load data in
file.  It really is a lot faster.

You can completely remove Python from the picture when importing the
file.  Here's an example:

mysqlimport \
--user=user \
--password=password \
--columns=id,name \
--compress \
--fields-optionally-enclosed-by='' \
--fields-terminated-by='\t' \
--lines-terminated-by='\n' \
--local \
--lock-tables \
--replace \
--verbose \
mydatabase mylocalfile.tsv

To write that tsv file, I used the csv module with:

DEFAULT_KARGS = dict(dialect='excel-tab', lineterminator='\n')


def create_default_reader(iterable):
Return a csv.reader with our default options.
return csv.reader(iterable, **DEFAULT_KARGS)


def create_default_writer(iterable):
Return a csv.writer with our default options.
return csv.writer(iterable, **DEFAULT_KARGS)

There's one more thing to keep in mind.  If you do a load data from
file using Python, make sure you pass  local_infile=True to MySQLdb's
connect function.

Happy Hacking!
-jj

On Wed, Jun 11, 2008 at 6:15 PM, Pete Wright [EMAIL PROTECTED] wrote:

 That's an awesome tip - thanks so much guys for pointing me in a far
 less painful direction. My only concern now is speed in working with
 the file and minimizing wait states. For example, I presumably don't
 want anything writing to the text file while I'm loading it into the
 database, and similarly I don't want to take time on every single
 request to check the size of the text file to see if I should run a
 LOAD DATA on it.

 So, I think what I'm going to end up doing here is converting time
 into seconds since midnight and then mod 60 it to come up with a file
 name suffix. I'll also have another process running separately
 processing and deleting unecessary files. Do you guys see any problems
 with that method?


 On Jun 11, 6:58 pm, Jonathan Vanasco [EMAIL PROTECTED] wrote:
 write to a .txt log in some sort of standardized format , when it hits
 10k lines run a batch query

 as mentioned above, mysql has its own insert format; postgres does
 too.  both insert formats are FAR faster than going through individual
 inserts.

 when i still used mysql about 4 years ago, i remember benching an
 insert of geographic data.  it was something like 6 hours via inserts,
 4hours via grouped inserts, and 25 seconds using the native import
 format.
 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Difference between controllers and views?

2008-06-11 Thread Shannon -jj Behrens

On Wed, Jun 11, 2008 at 3:14 PM, Ben Bangert [EMAIL PROTECTED] wrote:
 On Jun 11, 2008, at 1:10 PM, Karlo Lozovina wrote:

 What's the practical difference between controller based approach and
 views based one? Eg. Django views, and controllers in Pylons? It
 doesn't seem that much different, so why not make all controller
 actions regular functions, instead of class methods? What's the gain
 in this controller approach, if any? :)

 Terminology really. Note that webapps in general are only vaguely mapped to
 the entire MVC concept in that you have a model representing domain logic
 (generally with a database), a controller that gets the request and decides
 how to respond, and a view (template) which the controller uses to create
 the response with the data (Model).

 So Django is more-or-less MVC, they just call it MTV (Model-Template-View),
 and their 'View' is doing the logic with the request, fetching data from the
 Model, and using a template (aka, view), to return a response. By any
 definition of MVC I've seen, Django is without a doubt MVC as well:
 http://en.wikipedia.org/wiki/Model-view-controller

 They've provided a reason for why they choose to call it MTV on their FAQ
 page, which differs from every other web frameworks rather unanimous
 interpretation of it, and so far has led to more than a little confusion
 when I've seen Django users using other MVC frameworks and frequently asking
 about 'views' when people understand that to be 'controllers'.

 Regarding the use of a class vs a function for the controller, there are
 some advantages with the class. You can easily have stuff done before any of
 the methods are called for example, and you can set things on the class
 object and have helper function utilized that have access to them on 'self'
 as well. Also, you can develop mix-in style classes, to easily add generic
 methods to various controllers merely by changing the inheritance.

MVC is a cargo cult ;)

http://jjinux.blogspot.com/2005/04/mvc-cargo-cult.html

I agree with Ben.  Having classes with methods has all sorts of OO
benefits.  Consider, you can implement __getattr__ and do all sorts of
cool tricks.  It's also nice to share a bunch of code and data via
self.  If you don't use classes, you're forced to do everything with
function decorators.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: paster make-config issue

2008-06-11 Thread Shannon -jj Behrens

On Wed, Jun 11, 2008 at 9:51 AM, Ian Bicking [EMAIL PROTECTED] wrote:

 Jean Parpaillon wrote:
 Hi all,
 When using paster make-config, generated file is automatically added to svn.
 Is there a way to disable it ? Why is it the default behaviour ? (Generated
 files are usually not versioned !)

 paster automatically adds files to svn when the containing directory is
 an svn checkout.  I never really considered that this would happen with
 make-config; you can control it with ensure_file(svn_add=False).

 Though the file is initially generated, it's intended to be hand-edited
 and is just a starting point.  It's not a generated file in the style of
 a .pyc file.

When Paste generates something for me, I immediately check it in.  I
use the command used to generate the file as my svn comment.  Later,
when I check in changes to the file, I can use diff to see how I've
changed the default.

This comes in handy if you need to do a three way merge between how
Pylons/Paste used to generate something, how it generates something
now that it's been updated, and the file that you currently have.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons Session help

2008-06-10 Thread Shannon -jj Behrens

On Mon, Jun 9, 2008 at 1:26 PM, Mike Orr [EMAIL PROTECTED] wrote:

 On Mon, Jun 9, 2008 at 1:50 AM, Krishgy [EMAIL PROTECTED] wrote:

 Hi,

 I am working on a community website, using pylons.

 I needed to capture the user navigation by recording user interaction
 with the web site. I will store the urls with the query string (GET
 method, query param shall help me to understand what they are
 searching/looking) corresponding to the special session/cookie id.

 All I need is to setup a middleware in the pylons application stack.

 1. When a request comes, middleware has to see the session id
 generated
 2. If the session id present, it has to log the url with the session
 id/specific identifier to follow the requests
 3. Either db/file, i can log the file

 Any idea how to achieve this?

 (Don't worry about privacy, integrity issues. This is purely
 technical, to analyze what user like the most in the site)

 paste.translogger.TransLogger does an Apache-style transaction log.
 You can override the .write_log() method to make it log more
 information.  The session is environ[beaker.session], and the
 session ID is
 environ[beaker.session].id .  You can also override the format
 attribute to make trivial changes to the format.   I hate the Apache
 format so I log to a CSV file, which makes my .write_log() rather
 large.

I've had good luck recently parsing Apache logs with the apachelog
module: http://code.google.com/p/apachelog/.  I even wrote a little
wrapper that parsing Apache logs and outputs CSV ;)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: How did you begin your fun with Pylons?

2008-05-30 Thread Shannon -jj Behrens

I'm not making any judgments about anyone.  However, I did see a great
talk yesterday called How Open Source Projects Survive Poisonous
People: http://youtube.com/watch?v=ZSFDm3UYkeE

It's definitely worth watching ;)

-jj

On Thu, May 29, 2008 at 9:33 PM, Jonathan Vanasco [EMAIL PROTECTED] wrote:


 On May 29, 8:07 am, Alberto Valverde [EMAIL PROTECTED] wrote:
 Perhaps a trip to archives [1] to refresh your memory on the tone of some
 of your posts can shed a light on the reason you felt treated in this way
 by TG's dev. community.

 Perhaps my tone got increasingly negative as a response to poor
 treatment.

 I constantly created patches to bring TG's SqlAlchemy support in line
 with the SqlObject -- as one was supported and another was
 'experiemental'.  I would then be derided for trying to instill new
 design patterns -- which were exact clones of Kevin's 'official'
 sqlobject work.

 On top of that, every bit of new functionality I offered and coded to
 the TG community as a patch set was summarily rejected... then 2-8
 months later I would receive an email saying So we realized that we
 should have gone in this direction... would you mind updating your
 patch to the new codebase?

 




-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: advice with configuration/scaling a live Pylons app.

2008-05-30 Thread Shannon -jj Behrens

On Fri, May 30, 2008 at 12:49 AM, Graham Dumpleton
[EMAIL PROTECTED] wrote:

 On May 30, 12:56 pm, Mike Orr [EMAIL PROTECTED] wrote:
 On Thu, May 29, 2008 at 4:30 PM, Graham Dumpleton



 [EMAIL PROTECTED] wrote:

  On May 29, 7:29 pm, Alex Marandon [EMAIL PROTECTED] wrote:
  2008/5/29 Alex Marandon [EMAIL PROTECTED]:

   2008/5/28 SamDonaldson [EMAIL PROTECTED]:
   Running ab benchmark tests revealed many requests were failing.
   Should I be starting MORE Paster processes to handle the load?  Is
   this the right thing to do, or is the Paster (SCGI) process itself
   multi-threaded to handle such synchronous requests.  Say the Paster
   process is doing some I/O (SQL query through sqlalchemy), would that
   process block and would other requests wait, or would they get
   serviced?

   Hi Sam,

   According 
   tohttp://wiki.pylonshq.com/display/pylonscookbook/Pylons+Execution+Anal...
   paster is multithreaded. It should be easy to test. Hit a controller
   action that sleeps for 10 seconds and see if you can still make
   requests to other actions. I actually need to test for myself as soon
   as I get to work. As for why you get failed requests, I don't know.

  class FooController(BaseController):

  def bla(self):
  return 'Hello World! %s' % time.time()

  def slow_bla(self):
  time.sleep(10)
  return 'Hello slow World!'

  With something like that, manual testing works just fine (ie: I'm able
  to hit the action bla as many times as I want while the action
  slow_bla is still serving).

  When testing with ab though, I do get failed requests, but I actually
  get even more failed requests with Apache/mod_wsgi.

  What options are you using to 'ab'?

  The 'ab' program can give a perception of errors, normally manifesting
  as lots of exceptions on server side in log file, if you use
  concurrent requests. This occurs because it only stops when it
  receives responses for the number of requests you tell it to make.
  With a request handler that takes a long time, because of a sleep()
  call, the 'ab' program can actually issue more requests than you tell
  it to. When it does receive responses for the number you told it, it
  will simply shutdown the connections for all the additional requests
  it made which it hasn't yet received a response. The result of this is
  that on the server side it will see a bunch of closed connections
  causing failures to be able to write the responses for the additional
  requests.

  The end result is that one thinks that the hosting mechanism is having
  problems, when in fact it is due to how the 'ab' program works.

 That's akin to the user pressing the Stop button in the browser.  I
 get a connection reset line for that in my Quixote apps but not in
 my Pylons app.  I assumed Pylons just ignored the exceptions because
 it's not really an error if the client goes away.  But in any case, I
 don't get socket errors in my Pylons error log, and I can't assume
 that's because nobody ever presses Stop.  So if Alex is getting such
 errors, the question is why the difference in behavior?

 For mod_wsgi at least, it is a bit pendantic and errs on the side of
 logging such events on the basis that in some cases it may actually be
 because of problems in code and/or the user may want to know.

 There is an issue for mod_wsgi related to this where speculated that
 it could be made less noisy on such issues where it makes sense:

  http://code.google.com/p/modwsgi/issues/detail?id=29

 and/or whether the messages are displayed dependent on logging levels.

 At the time it was low priority and haven't since had a chance to get
 around to looking at it more closely, but will be doing so in next
 round of code changes.

From a couple years of experience, here's the code that ended up in
Aquarium's Web server, glass.  You're welcome to take it for Pylons or
Paster if you find it useful.

def is_disconnect_error(self, e):
Is ``e`` an error like ``errno.EPIPE`` or ``errno.ECONNRESET``?

Various types of sockets might represent disconnect errors differently.
Hopefully, one of the ways I've coded will apply.


if (isinstance(e, socket.error) or
isinstance(e, exceptions.OSError) or
isinstance(e, exceptions.IOError)):
errnos = [errno.EPIPE, errno.ECONNRESET]
if len(e.args) and e.args[0] in errnos:
return True
if getattr(e, errno, None) in errnos:
return True
return False

Best Regards,
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Re: advice with configuration/scaling a live Pylons app.

2008-05-30 Thread Shannon -jj Behrens

On Fri, May 30, 2008 at 5:12 AM, Alex Marandon [EMAIL PROTECTED] wrote:

 2008/5/30 Graham Dumpleton [EMAIL PROTECTED]:
 class FooController(BaseController):

 def bla(self):
 return 'Hello World! %s' % time.time()

 def slow_bla(self):
 time.sleep(10)
 return 'Hello slow World!'

 With something like that, manual testing works just fine (ie: I'm able
 to hit the action bla as many times as I want while the action
 slow_bla is still serving).

 When testing with ab though, I do get failed requests, but I actually
 get even more failed requests with Apache/mod_wsgi.

 What options are you using to 'ab'?

 -n 1000 -c 3

 The 'ab' program can give a perception of errors, normally manifesting
 as lots of exceptions on server side in log file, if you use
 concurrent requests. This occurs because it only stops when it
 receives responses for the number of requests you tell it to make.
 With a request handler that takes a long time, because of a sleep()
 call, the 'ab' program can actually issue more requests than you tell
 it to. When it does receive responses for the number you told it, it
 will simply shutdown the connections for all the additional requests
 it made which it hasn't yet received a response. The result of this is
 that on the server side it will see a bunch of closed connections
 causing failures to be able to write the responses for the additional
 requests.

 Note that I didn't test against the action that does a sleep. I'm a
 bit confused by your explanation. Does it mean that the errors should
 show up in the logs on the server side? I was only looking at ab's
 output.

I have a few comments:

* First of all, within the last few weeks, there was a massive thread
about the best way to deploy Pylons applications.  That's a must read.
 Personally, I opted for Nginx with Paster, but YMMV.  My situation is
a bit strange anyway.

* There were a couple good points made above about whether to run one
or multiple copies of Paster.  It's true that this is one place where
Pylons/Python is very different from Rails/Ruby, as mentioned above.
If you're mostly blocking on IO, then multiple copies won't help much
since multithreaded programs are fine in Python if they're IO
constrained.  If you're blocking on CPU, then multiple copies of
Paster running are a really good idea, otherwise the GIL will get in
the way of your making use of multiple cores.

* Socket connections have a setting for how many requests are allowed
to wait in the queue before being accepted.  I don't know what the
setting for Paster is or how to change it.  I do know that I've used
ab before, and it hit this limit.  This is the likely cause of
Connection Denied errors.

* ab is a bit simple minded to begin with.  I've told it to use 100
concurrent requests (which I saw that you didn't do), and it saw all
sorts of failed connections.  Of course, getting 100 *concurrent*
requests isn't all that common for most production servers.  If you
were able to handle 100 concurrent requests, and process each in 0.1
seconds, that would lead to 86,400,000 requests a day!  Yeah, I wish
;)  JMeter is nice in that it allows you to script how a real user
would behave.  I've also heard that HTTP Perf is nice, but I haven't
tried it.

* I saw a great talk on Google App Engine yesterday where one of the
speakers was criticizing naive load testing.  He said that if you slam
a Google App Engine app, it doesn't have enough time to warm up a
bunch of Python interpreters to serve your app.  It'll perform poorly.
 However, if you test a more sustained, realistic, and organic growth
rate, the infrastructure organically grows to scale.  It was
interesting.

Anyway, happy hacking, and best of luck!

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Deployment Question

2008-05-24 Thread Shannon -jj Behrens

On Fri, May 23, 2008 at 2:26 PM, Jonathan Vanasco [EMAIL PROTECTED] wrote:

 On May 23, 3:48 pm, Mike Orr [EMAIL PROTECTED] wrote:
 This is quite interesting.  I've been looking for a way to build a
 site scraper (something analogous to an aggregator but more
 site-specific) that could eventually become asynchronous, and this
 looks a lot easier than Twisted.

 FindMeOn's spiders are Twisted; importing contacts/relationships/
 profiles from 40+ social networks.

 We're looking at redoing it in Erlang - Twisted was too slow.

 I'd be happy to share some code with you privately if it'll help you
 get your own project on track.

Bob Ippolito was telling me once that he took a server in Twisted and
rewrote it in stackless.  He got some performance gains, but then he
rewrote it in Erlang.  It dropped from 40% CPU utilization to almost
nothing, and it was a heck of a lot faster.  In some situations,
Erlang is a really nice tool.  Now, if only the syntax wasn't so
ridiculously ugly ;)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Cross-Project code sharing...modules/plugins what does Pylons use?

2008-05-24 Thread Shannon -jj Behrens

On Sat, May 24, 2008 at 6:37 AM, rcs_comp [EMAIL PROTECTED] wrote:
 Hello all,

 I am new to the Python web-programming world and trying to decide on
 frameworks.  I was really impressed with Django, but ran into some
 problems with IIS hosting.  Since Pylons had really nice install
 instructions for IIS, I started to take a look and I like the
 philosophy.  The WSGI from the ground up mentality seems to be a real
 plus.

 However, I have run across a show stopper for me with Pylons unless I
 have missed something in the documentation.  Does Pylons support some
 kind of module/plugin architecture that will allow me to develop plug-
 in functionality across Pylons projects?  What would be called in
 Django an app.

 For example, I would like to have a news, blog, and calendar
 module that I can plug into different applications.  The goal is to
 have everything for the module contained in one subdirectory including
 any configuration, routing, templates, controllers, model, etc.  So,
 something like this:

 /modules/news/...
 /modules/calendar/...
 /modules/blog/...

I'm sure others will say something different, but my approach has
always been to simply run multiple apps on separate subdomains.
Subdomains are free ;)  In the past, I had login.foxmarks.com,
my.foxmarks.com, and www.foxmarks.com.  Each of the apps were
completely separate, but I used Genshi to create a common look and
feel.

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: How did you begin your fun with Pylons?

2008-05-23 Thread Shannon -jj Behrens

On Fri, May 23, 2008 at 1:38 AM, Christoph Haas [EMAIL PROTECTED] wrote:
 On Freitag, 23. Mai 2008, Mike Orr wrote:
 On Thu, May 22, 2008 at 11:46 PM, Raoul Snyman [EMAIL PROTECTED]
 wrote:
  I will have to agree with the sentiments already voiced here. The
  documentation is very sparse, and it relies on the user having a good
  understanding of MVC frameworks (like RoR and CakePHP).

 I wish Christoph were here because he wrote an extensive intro to
 Pylons covering precisely this.  I just don't know where his latest
 version is.

 You rang? :) I had once upon a time started an introcution at

http://wiki.pylonshq.com/display/pylonscookbook/Concepts+of+Pylons

 I received a lot of positive feedback about it and started working on a
 longer article. The last state of work can be found at

http://workaround.org/pylons/beginning-pylons.html

 Then Ben started calling for more documentation for the 0.9.7 documentation
 and introced Sphinx and put the documentation under

http://docs.pylonshq.com

 After a little chit-chat with Ben I agreed to put further work on the
 article into the official docs and submitted an introductional chapter.
 Ben didn't seem to get it online yet and Graham Higgins has also written
 something on the topic. So I think Ben still has merging the two documents
 on his todo list. At least I hope my text doesn't just vanish. Anyway,
 Graham's work in progress is currently at

http://bel-epa.com/pylonsdocs/index.html

 which also contains an About Pylons chapter. My own contribution can be
 read at

http://workaround.org/pylons/docs/introduction.html

 which is apparently not yet merged into the official docs. Ben didn't tell
 me that I got fired so I still have faith. :)

 I assume the confusion is complete now with all the URLs. But I'm very
 convinced that moving all the wiki mess into one consistent documentation
 (at docs.pylonshq.com) is the right way. And I hope that it's get done
 soon.

Noah, there's your cue ;)  All the information is there, you just have
to cat | sort | uniq it ;)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Deployment Question

2008-05-23 Thread Shannon -jj Behrens

On Fri, May 23, 2008 at 12:32 AM, Lawrence Oluyede [EMAIL PROTECTED] wrote:

 On Thu, May 22, 2008 at 11:12 PM, Shannon -jj Behrens [EMAIL PROTECTED] 
 wrote:
 Has anyone tried out the mod_wsgi module for *Nginx*?  Yeah, I know,
 weird: http://wiki.codemongers.com/NginxNgxWSGIModule

 I personally know the author and I definitely recommend it. He's
 focused and competent.

Oh, cool!

 Being asynchronous rules!  That's why Erlang, Squid, IronPort servers,
 Nginx, etc. are able to handle so many concurrent requests so easily.
  Here's the link to the C10K paper referenced earlier:
 http://www.kegel.com/c10k.html.  It explains why a thread or process
 model doesn't cut it if you want to handle 10K simultaneous requests.

 There's just only a little problem with async: it does not scale on
 multicore architectures or multiple nodes.
 At least not by itself. You have to mix it with other kinds of
 concurrency approaches to gain advantage of that.
 Erlang is async but it does scale everywhere by the way it was built.

Haha, when you said it didn't scale for multiple cores or multiple
nodes, I was going to knee jerk and say, What about Erlang!  You
beat me to the punch ;)  Yes, async is a technique.  Just like event
based programming in general is a technique.  You still have to use
that technique in smart ways to build big systems.

 If you're interested in doing asynchronous programming in Python but
 without the painful callback style approach used by Twisted, check out
 http://wiki.secondlife.com/wiki/Eventlet.  It's based on the same
 tricks used by Yahoo Groups, IronPort, and Slide.

 I will definitely look into it! Thanks. Have you tried it for
 something real-worldish or just examples?

I haven't used Eventlet yet.  It's based on the same ideas that
IronPort uses, and clearly, IronPort servers are all over the world.
It's nice because it feels like threads, but it acts like async.

 As usual, I recommend that anyone who wants to talk about scalability
 read Scalable Internet Architectures.  Gees, I probably sound like a
 broken record concerning that book ;)

 Noted. I am reading Building Scalable Websites at the moment but I
 will buy it afterwards

I read that one too.  It's a big long and boring, eh?  Scalable
Internet Architectures was a bit more to the point, and it includes a
lot more stuff about scalability per se.

I blogged about both of them:
http://jjinux.blogspot.com/search?q=scalable+internet+architectures
http://jjinux.blogspot.com/2006/11/book-review-building-scalable-web.html

Happy Hacking!
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Deployment Question

2008-05-22 Thread Shannon -jj Behrens

Here's my two cents:

Has anyone tried out the mod_wsgi module for *Nginx*?  Yeah, I know,
weird: http://wiki.codemongers.com/NginxNgxWSGIModule

Being asynchronous rules!  That's why Erlang, Squid, IronPort servers,
Nginx, etc. are able to handle so many concurrent requests so easily.
 Here's the link to the C10K paper referenced earlier:
http://www.kegel.com/c10k.html.  It explains why a thread or process
model doesn't cut it if you want to handle 10K simultaneous requests.

If you're interested in doing asynchronous programming in Python but
without the painful callback style approach used by Twisted, check out
http://wiki.secondlife.com/wiki/Eventlet.  It's based on the same
tricks used by Yahoo Groups, IronPort, and Slide.

As usual, I recommend that anyone who wants to talk about scalability
read Scalable Internet Architectures.  Gees, I probably sound like a
broken record concerning that book ;)

Finally, a plug for my article (if you don't mind).  If you want to
learn more about concurrency approaches in Python, checkout my
article: http://www.ddj.com/linux-open-source/206103078

Thanks for your patience ;)
-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: How did you begin your fun with Pylons?

2008-05-22 Thread Shannon -jj Behrens

On Thu, May 22, 2008 at 7:37 AM, Mikeroz [EMAIL PROTECTED] wrote:
 Hey guys,
 I'm wondering where did you start your journey with Pylons?

Ben Bangert and I decided to meet for dinner in Berkeley.  I got very
lost and ended up in Oakland.  I finally got to the restaurant an hour
late.  Ben had already eaten.  We had a good talk about Web
development.  He told me he wanted to write a new Python Web
application framework.  I tried to talk him out of it.  He didn't
listen to me ;)

-jj

-- 
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Authkit - colliding cookies

2008-05-19 Thread Shannon -jj Behrens

On Sun, May 18, 2008 at 7:10 AM, Moshe C. [EMAIL PROTECTED] wrote:
 Hi,

 I have two parallel applications running from the same host but on
 different ports.

 How do I configure Authkit so that each one creates a unique cookie.

 Currently if you log into one app, you are also authenticated for the
 other.
 The cookie name is the host name.

Normally, the cookie is specific to a (protocol, host, port) triple
(I'm hand waiving a bit).  Are you doing some weird sort of proxying
with Apache so that the two different apps are both available under
port 80 but with different paths?  That's the only thing I can think
of that would cause this behavior.  Don't forget, you can also use
separate subdomains.

Best Regards,
-jj

--
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Beaker Trunk With Appengine

2008-05-19 Thread Shannon -jj Behrens

On Fri, May 16, 2008 at 11:16 AM, Anil [EMAIL PROTECTED] wrote:
 I am trying to run pylons with google app engine and everything is
 working perfectly locally, but when I upload the site live beaker
 gives me the following error. Anyone have any idea on where to start
 debugging?  http://pastebin.com/m7fc2a3c7

I'm going to hazard some guesses:

* You're not saving sessions to disk, are you?  Clearly that won't work.
* I wonder if this has to do with the fact that your code is running
on multiple different servers.
* Why are you trying to pickle a function?  What's in your session?

-jj

--
I, for one, welcome our new Facebook overlords!
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



going off line

2007-06-15 Thread Shannon -jj Behrens

Hey guys,

As much as I love Pylons, I need to step off the list for a little
while.  If you need to ask me questions, feel free to send me email
directly.

Wish me luck with my fourth child which is due in two weeks!

Happy Hacking!
-jj

--
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons deployment methods

2007-06-09 Thread Shannon -jj Behrens

On 6/8/07, voltron [EMAIL PROTECTED] wrote:
 Thanks Shannon, but as I mentioned a few posts above, creating eggs
 worked in windows for me, not on Linux.

Sorry, my memory isn't all that great with the amount of email I read ;)

 What would be the correct
 syntax?

I create eggs using:

python setup.py bdist_egg

 I take it too be the same as in the docs, but this just threw
 horrible errors back at me

Sorry, I don't know why.

Best Regards,
-jj

 On Jun 7, 12:03 pm, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
  On 5/29/07, voltron [EMAIL PROTECTED] wrote:
 
 
 
   Ok, just to get things straight:
 
   1. I copy my app folder(the one with the development.ini in it) from
   my windows machine to my Linux server
 
   2. I run setup-app and this sets stuff up on my linux machine as it
   should
 
   Did I get it?
 
  Pretty close:
 
   * Create an egg.
   * Copy the egg to the server.
   * easy_install the.egg.
   * paster setup-app your.ini.
 
  Best Regards,
  -jj
 
 
 
   the way of the pylons is sometimes easy, but mostly secretive and
   tricky
 
   On May 29, 4:25 pm, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
On 5/29/07, voltron [EMAIL PROTECTED] wrote:
 
 This is another of my what is the best way questions.
 
 I would like to deploy my Pylons application without headaches on my
 clients server. This would mean my app with its templates and creating
 the database. A while back, Dan posted that he had init code in
 websetup.py and he called this at the command line:
 
 command-prompt# paster setup-app development.ini
 
 Taking a look at this line, I thought, typical of Pylons, got to
 break out the shovel again. After digging for a while I found this:
 
 def setup_config(self, command, filename, section, vars):
 0557
 0558Called to setup an application, given its configuration
 0559file/directory.
 0560
 0561The default implementation calls
 0562``package.websetup.setup_config(command, filename,
 section,
 0563vars)`` or ``package.websetup.setup_app(command, config,
 0564vars)``
 0565
 0566With ``setup_app`` the ``config`` object is a dictionary
 with
 0567the extra attributes ``global_conf``, ``local_conf`` and
 0568``filename``
 0569
 
 What I have discovered can be summed up as:
 
 1. Create an egg for deployment, this worked for me on windows, it did
 ´nt work on Ubuntu
 2. Copy the app folder to the target server, then run setup-app
 
 What is advised by the Pylons overlords?
 
Take another look at the QuickWiki tutorial.  It does its own database
setup using paster setup-app my.ini.  To answer your more high level
question, yes, setup-app is good to use :)
 
Happy Hacking!
-jj
 
--http://jjinux.blogspot.com/
 
  --http://jjinux.blogspot.com/


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: mod_python configuration?

2007-06-09 Thread Shannon -jj Behrens

On 6/7/07, Chris Shenton [EMAIL PROTECTED] wrote:
 Shannon -jj Behrens [EMAIL PROTECTED] writes:

  The current favorite way to run Pylons apps behind Apache is to proxy
  them and use Paster.  It's exactly the sort of problems that you ran
  into that make some of us wary of mod_python.

 I did get it working (expat problem, reported here with pointer to URL
 on diagnosing it).  But, would you care to share your proxy conf?

Unfortunately, I don't have access to the app anymore.  Perhaps this
will help you:

http://docs.pythonweb.org/display/pylonscookbook/Production+deployment+using+supervisor+Apache+as+a+reverse+proxy

Best of Luck,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Pylons jobs

2007-06-07 Thread Shannon -jj Behrens

I'm seeing a lot of Pylons-related jobs out here in Silicon Valley.  I
think that's a very good sign.

If anyone wants one, I know that both Wize and Metaweb are looking for
really solid Python guys who know Pylons.  Tell them I sent you.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: accessing request handler from BaseController

2007-06-07 Thread Shannon -jj Behrens

On 6/6/07, Max Ischenko [EMAIL PROTECTED] wrote:
 Hello,

  I am not very happy with the default validation scheme suggested by Pylons
 and trying to design my own.

  The idea is to let the code handle main code path (data is valid) and
 handle validation error separatedly. I want to be able to set
 validation_handler which is then invoked by BaseController when validation
 fails.

  E.g.

  class SomeController(BaseController)
  def index(self):
  code = get_request_param('code', validator=...)
  # do something with validated parameter code
  index.validation_handler = lambda errors: Response('Oops!')

  class BaseController(WSGIController):
  def __call__(self, environ, start_response):
  # ...
  try:
  return WSGIController.__call__(self, environ, start_response)
  except ValidationError, e:
  validation_handler = getattr(XXX, 'validation_handler', None)
 or default_validation_handler
  return validation_handler(e)

  I struggle to find the XXX object I can query to access the
 validation_handler (such as the one defined for index()).

  Any ideas?

Somewhere in the environ, there's the Routes stuff.  You can use that
to figure out which action was executed.  I usually just print out the
environ and start poking around.  Once you know what action was
executed, get the actual method via getattr(self, action_name).
From there, you can do getattr(action_method, 'validation_handler',
None).  Make sense?

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Using pater with other servers

2007-06-07 Thread Shannon -jj Behrens

On 5/30/07, voltron [EMAIL PROTECTED] wrote:
 I am trying to get Pylons to work with a web server that supports
 FCGI, the problem is, the server manges URLs with extentions like .php
 e.t.c which Pylons does not have. Are there some key things that I
 have to take notice of when trying to configure a server with Pylons?
 I inten to use Hiawatha

 http://hiawatha.leisink.org/

I know nothing about Hiawatha, but I do know it's not hard to setup
Routes so that it fakes a .py extension on all the URLs if that's what
makes it happy.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Subdirectories and resource paths in Mako

2007-06-07 Thread Shannon -jj Behrens

 Also, for static resources, like images or CSS files that actually are
 on the proxy server proxying for the Paster server, how can I pass a
 sort of /media path to my templates that would always be resolved no
 matter how deep the links are that are mapped?

Personally, I'm lazy, so I just use absolute paths for the static
resources.  Hence, I do things like /images/foo.png.  I'm sure some
badly behaving proxy out in the wild will bite me one of these days,
but it hasn't yet.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Custom error documents

2007-06-07 Thread Shannon -jj Behrens

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

 I wish we could edit posts. Anyway, I took a look at the docs again,
 so I modified my error.py accordingly, but I still get a trace:


 response = self._dispatch_call()
   File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
 \controllers.
 py, line 161, in _dispatch_call
   File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
 \controllers.
 py, line 161, in _dispatch_call
 response = self._inspect_call(func)
 response = self._inspect_call(func)
   File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
 \controllers.
 py, line 135, in _inspect_call
   File c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
 \controllers.
 py, line 135, in _inspect_call
 result = func(**args)
 result = func(**args)
   File D:\Projects\Pylons_projects\gameolymp\gameolymp\controllers
 \error.py, l
 ine 24, in document
   File D:\Projects\Pylons_projects\gameolymp\gameolymp\controllers
 \error.py, l
 ine 24, in document
 my_template=
 my_template=
 AttributeError: MultiDict instance has no __call__ method

 Any idea what I´m doing wrong?

You probably already fixed this by now, but I'll answer anyway.
Generally, if you see instance has no __call__ method that means you
wrote something like a() and a isn't a function like you think it
is.  In this case, it's a MultiDict, i.e. request.params.  I don't see
where you're doing something like request.params(...), but
conceptually, something like that is happening.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: mod_python configuration?

2007-06-07 Thread Shannon -jj Behrens

On 5/29/07, 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 from
 http://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?

The current favorite way to run Pylons apps behind Apache is to proxy
them and use Paster.  It's exactly the sort of problems that you ran
into that make some of us wary of mod_python.

(Hi, Alec!)

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: use of globals, threadless, and requests

2007-06-07 Thread Shannon -jj Behrens

On 5/29/07, alecf [EMAIL PROTECTED] wrote:
 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.

Ah, stackless ;)

 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?

I suspect you're going to need to override some code to do things the
stackless way using the stackless notion of thread local storage.
Strangely enough, this same thing happened to me using a proprietary
version of stackless in my framework Aquarium.

If I were in your shoes, I might spend some time figuring out
different ways to monkey patch things (either by making tasklets
masquerade as threads or by swapping in some code into Paste).  Just
look at the code for what Paste is actually doing and figure out what
you wish it were doing and see if you can do some magic to make it
work.

 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.

In Aquarium I made the design decision that you had to get everything
from the ctx for exactly this reason.  That's why Aquarium adapted to
stackless so easily.  However, the stacked object proxies are
syntactically convenient--the cost is that they're tied to the normal
Python threading API.

 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.

Yep.

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

You're a smart guy ;)  You'll figure it out ;)  Tell us how it goes.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons deployment methods

2007-06-07 Thread Shannon -jj Behrens

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

 Ok, just to get things straight:

 1. I copy my app folder(the one with the development.ini in it) from
 my windows machine to my Linux server

 2. I run setup-app and this sets stuff up on my linux machine as it
 should

 Did I get it?

Pretty close:

 * Create an egg.
 * Copy the egg to the server.
 * easy_install the.egg.
 * paster setup-app your.ini.

Best Regards,
-jj

 the way of the pylons is sometimes easy, but mostly secretive and
 tricky

 On May 29, 4:25 pm, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
  On 5/29/07, voltron [EMAIL PROTECTED] wrote:
 
 
 
   This is another of my what is the best way questions.
 
   I would like to deploy my Pylons application without headaches on my
   clients server. This would mean my app with its templates and creating
   the database. A while back, Dan posted that he had init code in
   websetup.py and he called this at the command line:
 
   command-prompt# paster setup-app development.ini
 
   Taking a look at this line, I thought, typical of Pylons, got to
   break out the shovel again. After digging for a while I found this:
 
   def setup_config(self, command, filename, section, vars):
   0557
   0558Called to setup an application, given its configuration
   0559file/directory.
   0560
   0561The default implementation calls
   0562``package.websetup.setup_config(command, filename,
   section,
   0563vars)`` or ``package.websetup.setup_app(command, config,
   0564vars)``
   0565
   0566With ``setup_app`` the ``config`` object is a dictionary
   with
   0567the extra attributes ``global_conf``, ``local_conf`` and
   0568``filename``
   0569
 
   What I have discovered can be summed up as:
 
   1. Create an egg for deployment, this worked for me on windows, it did
   ´nt work on Ubuntu
   2. Copy the app folder to the target server, then run setup-app
 
   What is advised by the Pylons overlords?
 
  Take another look at the QuickWiki tutorial.  It does its own database
  setup using paster setup-app my.ini.  To answer your more high level
  question, yes, setup-app is good to use :)
 
  Happy Hacking!
  -jj
 
  --http://jjinux.blogspot.com/


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: accessing request handler from BaseController

2007-06-07 Thread Shannon -jj Behrens

On 6/7/07, Max Ischenko [EMAIL PROTECTED] wrote:
 Hello,

 On 6/7/07, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 
  Somewhere in the environ, there's the Routes stuff.  You can use that
  to figure out which action was executed.  I usually just print out the
  environ and start poking around.  Once you know what action was
  executed, get the actual method via getattr(self, action_name).
  From there, you can do getattr(action_method, 'validation_handler',
  None).  Make sense?

  It makes sense, yes, except that I can't find that object in the environ.

  I  found pylons.routes_dict which is simply {'action': u'index',
 'controller': u'setlang', 'id': None}.

  Any further ideas?

Heh, that's exactly what you want!

method = getattr(self, pylons.routes_dict['action'])
validation_handler = getattr(method, 'validation_handler', None)

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Subdirectories and resource paths in Mako

2007-06-07 Thread Shannon -jj Behrens

On 6/7/07, Philip Jenvey [EMAIL PROTECTED] wrote:


 On Jun 7, 2007, at 6:09 AM, Daniel Tang wrote:

  On 6/7/07, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
 
   Also, for static resources, like images or CSS files that
  actually are
   on the proxy server proxying for the Paster server, how can I pass a
   sort of /media path to my templates that would always be
  resolved no
   matter how deep the links are that are mapped?
 
  Personally, I'm lazy, so I just use absolute paths for the static
  resources.  Hence, I do things like /images/foo.png.  I'm sure some
  badly behaving proxy out in the wild will bite me one of these days,
  but it hasn't yet.
 
  Best Regards,
  -jj
 
  I actually came across this last week.  If for some reason, you
  want to install a Pylons application mapped to a subdirectory via
  mod_proxy and Paster, such as on WebFaction, you'll see that the
  404 error breaks (in that no images show up).  I guess Paster
  doesn't see that it's under a subdirectory, so it spits out the
  wrong absolute path.  I don't really have an answer to that yet,
  since I'm still fairly new to Pylons, but you could use a subdomain
  as well, which could work better.  Maybe.
 

 Use url_for and the WebHelper functions such as image_tag as they
 will always prefix urls with the appropriate SCRIPT_NAME value.

 Then when deployed on a subdir behind a reverse proxy, use
 PrefixMiddleware:

 http://pylonshq.com/docs/0.9.5/
 application_configuration.html#prefixmiddleware

On the subject of PrefixMiddleware, did any committers get a chance to
check out my code submission here:

http://www.webwareforpython.org/archives/message/20070509.232518.f56c4bb7.en.html

It even came with tests! :)

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Conditional database creation in websetup

2007-06-07 Thread Shannon -jj Behrens

On 6/7/07, voltron [EMAIL PROTECTED] wrote:
 I have meta.create_all() in my websetup.py file, this takes all the
 models in the models.py file and attempts to create a database based
 on the models found, can one code a conditional that asks beforehand
 exactly what databases it should create create? All I have are prints
 in my websetup but I dont know how to interact with meta.

If all else fails, you can always use the environment:

env SETUP_USER_DATABASE=1 SETUP_OTHER_DATABASE=0 paster setup-app foo.ini

In your websetup.py:

import os

...
if int(os.getenv('SETUP_USER_DATABASE', 0)):
self.setup_user_database()
...

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Odd behavior with paster and Pylons

2007-06-06 Thread Shannon -jj Behrens

On 6/3/07, Daniel Tang [EMAIL PROTECTED] wrote:
 I discovered some interesting behavior when using Pylons on WebFaction.  For
 some very odd reason that I can't discern, whenever I run paster inside of a
 Pylons command, even if I don't pass any arguments, it launches gconfd-2.
 Normally, I wouldn't notice, but WebFaction limits the number of long
 running processes you have, and I got e-mailed about it.  To top off the
 weirdness, it only seems to run when X forwarding is set up.  The easy
 solution is to disable X forwarding since it's useless, which I have, but
 I'm wondering if there's actually some sort of point to launching gconfd,
 since it doesn't appear to store anything.

It probably has nothing to do with Pylons or Paster.  It's probably
gconf trying to forward settings over a socket or something when
you're doing X forwarding.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Pylons deployment methods

2007-05-29 Thread Shannon -jj Behrens

On 5/29/07, voltron [EMAIL PROTECTED] wrote:
 This is another of my what is the best way questions.

 I would like to deploy my Pylons application without headaches on my
 clients server. This would mean my app with its templates and creating
 the database. A while back, Dan posted that he had init code in
 websetup.py and he called this at the command line:

 command-prompt# paster setup-app development.ini

 Taking a look at this line, I thought, typical of Pylons, got to
 break out the shovel again. After digging for a while I found this:


 def setup_config(self, command, filename, section, vars):
 0557
 0558Called to setup an application, given its configuration
 0559file/directory.
 0560
 0561The default implementation calls
 0562``package.websetup.setup_config(command, filename,
 section,
 0563vars)`` or ``package.websetup.setup_app(command, config,
 0564vars)``
 0565
 0566With ``setup_app`` the ``config`` object is a dictionary
 with
 0567the extra attributes ``global_conf``, ``local_conf`` and
 0568``filename``
 0569


 What I have discovered can be summed up as:

 1. Create an egg for deployment, this worked for me on windows, it did
 ´nt work on Ubuntu
 2. Copy the app folder to the target server, then run setup-app

 What is advised by the Pylons overlords?

Take another look at the QuickWiki tutorial.  It does its own database
setup using paster setup-app my.ini.  To answer your more high level
question, yes, setup-app is good to use :)

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: SQLAlchemy + MySQL + UTF-8 support - how?

2007-05-29 Thread Shannon -jj Behrens

On 5/29/07, David Smith [EMAIL PROTECTED] wrote:
 jj, I actually agree strongly with you regarding the potential dangers. My
 counter argument is that if you specify the encoding of the database in the
 config file to a different encoding than is in the mysql config file, don't
 you risk double-encoding anyway?

Double encoding should *theoretically* never happen because MySQLdb
knows if it has a unicode object or a UTF-8 string.

 Now that the bug is fixed in MySQLdb, and
 no other database needs such options, I'd prefer to promote the Unicode
 field as the proper way forward. SQLAlchemy should, via the MySQLdb module,
 determine at runtime the encoding of the database and translate from that
 encoding to unicode objects as necessary (as should any other ORM).

To tell you the truth, I don't feel strong either way.  As long as *I*
the application developer don't need to do the encoding, and as long
as the database and I agree about the encoding, it doesn't matter to
me who does it.

All the database drivers SHOULD support encoding for you.  After all,
not everyone uses SQLAlchemy.  Personally, I think this should have
gone in the DBAPI spec.  However, if someone wants to let SQLAlchemy
do the work, I don't have any objections.

Happy Hacking!
-jj

 Shannon -jj Behrens wrote:

 
  I'm not necessarily disagreeing with you, but I do think it's really
  bad practice to have your database confused about the encoding of the
  data that it's storing.  At one point, I had things messed up and the
  data in the database was double encoded.  Sure, it worked as long as I
  was using SQLAlchemy, but if I ever decided to use something else, I
  would have been in really bad shape.  Fortunately, they fixed that bug
  in MySQLdb.
 
  Happy Hacking!
  -jj




 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: storing SA mapped objects in beaker sessions

2007-05-28 Thread Shannon -jj Behrens

On 5/27/07, Anil [EMAIL PROTECTED] wrote:
 user_mapper = assign_mapper(ctx, User, user_table,
 properties = {
   'alerts': relation(Alert,
 cascade=all, delete-orphan)
   })
 alert_mapper = assign_mapper(ctx, Alert, alert_table)


 user = session[user]
 alert = model.Alert(form_result[name])
 user.alerts.append(alert)
 user.save_or_update()
 user.flush()


 I save a User SA object in session[user] in another page. Then, in
 this page, I try to add Alert objects to the user object. I get this
 exception.

 class 'sqlalchemy.exceptions.InvalidRequestError': Object
 'entic.models.Alert object at 0xcc2970' is already attached to
 session '13378672' (this is '12302224')

 Can someone give me pointers on how I can resolve this?

 Plus, are there any best practices for passing around SA mapped
 objects in beaker sessions?

I would say *don't* ;)

I wouldn't expect a SA object to be serializable.  It just doesn't
make sense to me.  I don't even want to think about complications with
the database and ACID, nor do I want to consider the scalability
concerns (the SA object should be tied to a particular SA session,
right?).

It just boggles my mind.  I would say put some other non-SA-specific
object in the session, and then redo the SA stuff once you get it out
of the session.

(Of course, I could be wrong, but I don't think so.)

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: genshi

2007-05-28 Thread Shannon -jj Behrens

On 5/27/07, Julien Cigar [EMAIL PROTECTED] wrote:
 Hello,

 I'm new to Pylons and a long-time Genshi user.

 I wondered how can I tell to Pylons that the rendered template (with Genshi) 
 should be in utf-8 / xhtml-strict ?

 I tried the following (middleware.py) but without success :
 config.template_engines = []
 config.add_template_engine('genshi', 'ias.templates', {'genshi.encoding' : 
 'utf-8', 'genshi.output' : 'xhtml-strict'})

 Any idea ?

 Thanks,
 Julien

Hi Julien,

I went down the path you're going down too at one point.  Then I
realized there's a reason that Kid and Genshi use HTML by default:

http://www.mozilla.org/docs/web-developer/faq.html#accept
http://webkit.org/blog/?p=68

Genshi let's you *type* XHTML, but *serve* HTML.  It's the best of
both worlds.  You can switch to serving XHTML as soon as IE actually
supports it and as soon as Mozilla stops telling you not to ;)

Of course, if you're a super advanced XHTML user doing something like
MathML, please feel free to ignore me! ;)

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: 'Address already in use' error

2007-05-28 Thread Shannon -jj Behrens

On 5/27/07, Christoph Haas [EMAIL PROTECTED] wrote:

 On Sun, May 27, 2007 at 01:55:55PM -0700, voltron wrote:
  one thing, just using kill process number on Linux, you would have
  to use kill -9, maybe its the same on OSX

 Better not. Sending the signal 9 (SIGKILL) is a very harsh way that may
 even lead to inconsistencies and make you need to reboot the system.
 Use a normal kill without any signal number and you should be fine.

 I have many coworkers who are so used to blindly sending signals 9
 around and wonder why their systems become instable. :)

I remember reading this great rant somewhere about the harmfulness of
using kill -9.  The post went so far as to say that if you actually
need to use kill -9, you should just uninstall the software because
it's garbage to begin with.  Alas, I couldn't find it via a quick
google.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Mod_python and Sessions?

2007-05-28 Thread Shannon -jj Behrens

On 5/26/07, rahul [EMAIL PROTECTED] wrote:
 Thanks for the info.

 I went out and used mod_fcgid and it worked flawlessly.

 I didn't think that paster serve being served behind apache was the
 perferred choice, as I automatically assumed that it is intended for
 development purpose as django's is. Now that being said, scince I have
 a working mod_fcgid running already, and setting up psater serve
 behind apache isn't much of a problem - is paster serve really much
 better than apache performance wise?

There was a big discussion about this a month or two ago.  Someone
whose name current escapes me (so sorry!) did a big comparison and
found that paster performed as well or better, and it was a lot easier
to deal with.

It's not like Django's server.  I've been using it in production for months.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Towards a more incremental test-driven-development in Pylons?

2007-05-28 Thread Shannon -jj Behrens

On 5/28/07, Agustin Villena [EMAIL PROTECTED] wrote:
 Hi all

 Researching patterns to test-driven-development in frameworks based on the
 model view controller, I found this interesting paper

 http://www.purpletech.com/articles/mvc/mvc-and-beyond.html

 In this pattern, there ios a mini-MVC for ecah page on top of the global
 MVC.

 Quoting
 Here, the Page Model (the Page Data objects) represents everything that
 will show up on the page, in what order, in what language, etc. The page
 model represents an overlapping set with the application model. It does not
 contain all the information in the application model, merely the subset that
 is necessary for the current page to render. However, it is not a subset,
 for it also contains other, additional information: for example, which user
 is currently logged in, or which page of search results is showing, or an
 error message based on an invalid field.

  The Page (View) Renderer objects, in turn, perform a transformation from
 the Page Data into HTML. The most logic performed by the Renderer should be
 no more sophisticated than simple conditionals or iteration on values and
 collections returned by the data model.

 Finally, the Page Servlet (Controller) receives the parameters, creates an
 appropriate Page Data (Model), and passes it to a Page Renderer
 (View).Thanks to this model, testing in very much incremental

 Quoting again
  Testability. MMMVC is much easier to test than previous architectures. You
 can test that the correct page model gets generated by passing known
 parameters to the controller and testing the page model it returns. You can
 also test the renderer by passing a known page model and testing its
 rendered output.

  Since UI testing is both more difficult and, arguably, less important
 (since errors in HTML rendering are more likely to be noticed by humans),
 you can reserve the bulk of your test cases for the page model. Indeed, some
 Agile programming teams either do not test the UI at all, or write only
 rudimentary UI tests; this shortcut is only desirable with a very thin UI
 layer on top of a full-fledged data model.

  For instance, if a Menu page must display the Soup du Jour (which changes
 every day), the page must not do Date today = new Date();
 int dayOfWeek = today.getDay();
 String soup = data.getSoupForDay(dayOfWeek);
 out.print(Soup du Jour:  + soup);

  instead, that functionality must be delegated to the Page Model. Why?
 Because otherwise, it becomes impossible to test that Thursday's correct
 soup is displayed... unless you're testing on Thursday. out.print(Soup du
 Jour:  + data.getSoupDuJour());

  Note that getSoupDuJour() (with no parameters) is not a member of the
 application data model. You must add it to the Page Model.


 To apply this approach in pylons:

 1) I must create a page-model oriented layer, that generates the specific
 data that the page controller needs.


 This is already easy in pylons


 2) Given a frozen data-set, pass it to the page-view (template) and check if
 it is rendered in ehe appropiate way.


 Well, here is my problem. I don´t know how to make this kind of test. Any
 advice?


 Thanks

I didn't read the link, but I can see what you're saying.  Here are a
couple tricks I can suggest:

* To test your controllers somewhat in isolation, instead of calling
render_response, call my_render_response which you write yourself.  In
my_render_response, in testing mode, you can simply return JSON, and,
in real mode, you can return a real page.  Then, you can test the data
in the JSON--i.e. the page model.

* Alternatively, in your site-wide layout, take the entire c object,
serialize it and shove it in an HTML comment.  Then, write a script
that can look for the HTML comment and deserialize it.  Wham--you
suddenly have a way to grab the entire c object from the HTML of any
generated page.  Of course this doesn't work for redirects or when
you're generating something other than HTML, but I think that's okay.

* I've seen a real test-driven development shop in action using Ruby
on Rails.  The way they did it was to use pre-arranged data in the
database and then test for the presence of data at specific places in
the HTML DOM like.  For instance, #name 'Charlie Tuna' asserts that
there must be a name element which contains the known string Charlie
Tuna.  This kind of testing is fully automated, of course.

Does that help?

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Installation problems

2007-05-28 Thread Shannon -jj Behrens

On 5/28/07, Calder [EMAIL PROTECTED] wrote:
 Hi,

 I'm new to Pylon, and I just installed it using easy_install.  It said
 it installed successfully, but when I start the first tutorial and
 type:
 paster create --template=pylons helloworld
 I get the following error:

 Traceback (most recent call last):
   File /usr/local/bin/paster, line 7, in ?
 sys.exit(
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
 command.py, line 76, in run
 invoke(command, command_name, options, args[1:])
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
 command.py, line 115, in invoke
 exit_code = runner.run(args)
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
 command.py, line 210, in run
 result = self.command()
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
 create_distro.py, line 69, in command
 self.extend_templates(templates, tmpl_name)
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
 create_distro.py, line 222, in extend_templates
 tmpl = entry.load()(entry.name)
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
 line 1829, in load
 if require: self.require(env, installer)
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
 line 1842, in require

 working_set.resolve(self.dist.requires(self.extras),env,installer))
   File /Library/Frameworks/Python.framework/Versions/2.4/lib/
 python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
 line 487, in resolve
 raise VersionConflict(dist,req) # XXX put more info here
 pkg_resources.VersionConflict: (PasteScript 0.9.7 (/Library/Frameworks/
 Python.framework/Versions/2.4/lib/python2.4/site-packages/
 PasteScript-0.9.7-py2.4.egg), Requirement.parse('PasteScript=1.3.2'))

 Thanks in advance for any help!

Did you try easy_install -U PasteScript?  Hmm, this sounds
familiar--it may be in the archives.

-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Class nesting or subclassing controllers

2007-05-28 Thread Shannon -jj Behrens

Just move you subclass into a different module, and it'll be fine.  By
the way, I'm a little bit confused about logically separate and group
link hierarchies.  Naturally, your link hierarchies don't have to
match the code.  Maybe I'm just understand what you mean.

Happy Hacking!
-jj

On 5/28/07, voltron [EMAIL PROTECTED] wrote:
 Hmm, thats sad, I was just trying to find a way to logically separate
 and group link hierarchies by calling:

 Controller.function
 Controller.SubClass.func

 and so on

 Oh well, I stick to creating controllers and imports

 Thanks!

 On May 26, 8:49 am, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
  On 5/25/07, voltron [EMAIL PROTECTED] wrote:
 
   Is it possible to nest classes in a controller class?
 
  Routes knows how to look at a URL and try to figure out the matching
  controller module - controller class - method name.  If you deviate
  from this too much, you will probably not find joy.  Of course, once
  you're inside the controller, you can do whatever you want, including
  call local classes.
 
   A way to use
   subclassed contollers would interest me too
 
  One controller class can subclass another.  No prob.  Is that what
  you're asking?
 
  Best Regards,
  -jj
 
  --http://jjinux.blogspot.com/


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Installation problems

2007-05-28 Thread Shannon -jj Behrens

Have a peek at:

http://groups.google.com/group/pylons-discuss/browse_thread/thread/e77d228577e99919/1d32c716931e45ad?lnk=gstq=PasteScriptrnum=5#1d32c716931e45ad

Best Regards,
-jj

On 5/28/07, Calder [EMAIL PROTECTED] wrote:

 Yep, tried that.  Still doesn't work.

 On May 28, 2:52 pm, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
  On 5/28/07, Calder [EMAIL PROTECTED] wrote:
 
 
 
   Hi,
 
   I'm new to Pylon, and I just installed it using easy_install.  It said
   it installed successfully, but when I start the first tutorial and
   type:
   paster create --template=pylons helloworld
   I get the following error:
 
   Traceback (most recent call last):
 File /usr/local/bin/paster, line 7, in ?
   sys.exit(
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
   command.py, line 76, in run
   invoke(command, command_name, options, args[1:])
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
   command.py, line 115, in invoke
   exit_code = runner.run(args)
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
   command.py, line 210, in run
   result = self.command()
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
   create_distro.py, line 69, in command
   self.extend_templates(templates, tmpl_name)
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/PasteScript-0.9.7-py2.4.egg/paste/script/
   create_distro.py, line 222, in extend_templates
   tmpl = entry.load()(entry.name)
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
   line 1829, in load
   if require: self.require(env, installer)
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
   line 1842, in require
 
   working_set.resolve(self.dist.requires(self.extras),env,installer))
 File /Library/Frameworks/Python.framework/Versions/2.4/lib/
   python2.4/site-packages/setuptools-0.6c5-py2.4.egg/pkg_resources.py,
   line 487, in resolve
   raise VersionConflict(dist,req) # XXX put more info here
   pkg_resources.VersionConflict: (PasteScript 0.9.7 (/Library/Frameworks/
   Python.framework/Versions/2.4/lib/python2.4/site-packages/
   PasteScript-0.9.7-py2.4.egg), Requirement.parse('PasteScript=1.3.2'))
 
   Thanks in advance for any help!
 
  Did you try easy_install -U PasteScript?  Hmm, this sounds
  familiar--it may be in the archives.
 
  -jj
 
  --http://jjinux.blogspot.com/


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Mod_python and Sessions?

2007-05-26 Thread Shannon -jj Behrens

On 5/25/07, rahul [EMAIL PROTECTED] wrote:
 Hello,
 I'm new to pylons. Started out a couple of days ago. Comming from
 django, I am attempting to move to pylons for my current project, and
 everything went smoothly until i got to the point of installing pylons
 on apache2 + mod_python.

 I followed the instructions on this page:
 http://docs.pythonweb.org/display/pylonscookbook/Production+deployment+using+mod_python

 Everything seemed to work fine, but my sessions just dosent seem to
 get saved when running from apache.

 It works fine when i do the paster serve command.

 Any ideas?

By the way, if you have the choice over how you deploy the thing, most
of us prefer to use paster serve proxied behind Apache instead of
using mod_python.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Class nesting or subclassing controllers

2007-05-26 Thread Shannon -jj Behrens

On 5/25/07, voltron [EMAIL PROTECTED] wrote:
 Is it possible to nest classes in a controller class?

Routes knows how to look at a URL and try to figure out the matching
controller module - controller class - method name.  If you deviate
from this too much, you will probably not find joy.  Of course, once
you're inside the controller, you can do whatever you want, including
call local classes.

 A way to use
 subclassed contollers would interest me too

One controller class can subclass another.  No prob.  Is that what
you're asking?

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: abort(), detail and the error controller

2007-05-26 Thread Shannon -jj Behrens

On 5/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hello!

 I am working on my first real Pylons application and so far everything
 is going really good!  Big thanks to all those involved for creating
 such a great web framework.

 I am just getting to adding users to my application.  I want to stop
 users from viewing data that isn't their own.  My gut reaction is to
 abort() and setup my error controller to display the error in a way
 that fits in with the rest of my application (using my Mako
 templates).  But I want to give the user a specific message about why
 they can't go there.

 So, I tried:

 abort(403, Can't access another users data)

 The second argument is detail which gets passed to the
 paste.httpexceptions.HTTPForbidden object and thrown.  This seems like
 a really useful place to keep an application specific message.
 However, when the exception is converted to wsgi response by the
 paste.httpexceptions middleware, this information is lost.  So, that
 isn't going to work.

 My questions are:

  (1) Is the exception object stored anywhere?  It would be great if it
 was dropped into the environ somewhere, but best I can tell from the
 paste source code, it isn't.

  (2) Is there a better way to do this?  I imagine having lots of
 errors like this with simple one line messages.  I could create my own
 middleware to catch application specific exceptions and forward them,
 but this seems like overkill.  Is there a suggested way to accomplish
 this?

 Thanks in advance!

Yep, I've encountered this same difficulty.  In your case, probably
the best thing to do is to do a render_response using an error
template.  If you *really* want to take matters into your own hands,
write your own middleware that *wraps* the Paste exception handling
middleware.  I didn't do that, although I've done it for other things.
 Also, see the trick I wrote about here:

http://jjinux.blogspot.com/2007/03/python-returning-multiple-things-of.html

When I wrote that, I was facing the same issue you are facing.

Happy  Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Free blog application

2007-05-26 Thread Shannon -jj Behrens

On 5/26/07, Jonas Melian [EMAIL PROTECTED] wrote:
 Is there any FLOSS blog system using Pylons?

I've heard that blogs that use Pylons are more interesting to read ;)

/me giggles

-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Daemonizing and auto-restart

2007-05-25 Thread Shannon -jj Behrens

Pylons and Paste are meant to run in a wide variety of OSs.  This is
the type of stuff where it makes sense to take advantage of what your
particular OS provides.  For me on Ubuntu, that was runit.

My $0.02,
-jj

On 5/25/07, voltron [EMAIL PROTECTED] wrote:
 What actually is recommended by the Pylons gurus? The monitor and
 reload functions are there for a purpose, are they to be used in
 production?

 Thanks

 On May 25, 7:49 am, Max Ischenko [EMAIL PROTECTED] wrote:
  On 5/25/07, Mike Orr [EMAIL PROTECTED] wrote:
 
 
 
 
 
   On 5/22/07, Ian Bicking [EMAIL PROTECTED] wrote:
 My other question is, paster has a --monitor-restart option to restart
 the server if it dies.  But the Pylons Cookbook has recipes for
 daemontools and supervisor2.   Are these better than paster's monitor
 for some reason, or are they all interchangeable?
 
They all work the same basic way.  paster's is simpler, obviously, since
it's just one option.  But it hasn't been tested a whole lot, so I
dunno.  Also it probably has more overhead than daemontools, though I
don't know if it really is significant.
 
   I looked through supervisor2 and am really impressed with its
   features, but I couldn't get it to run my application and it wouldn't
   say why not.  According to the docs, this happens frequently for a few
   reasons that didn't seem to apply.  I wish it would take more care to
   write a specific error message.
 
   I suspect the problem was needing to set the PATH and PYTHONPATH to
   match my workingenv.  I used the beta version of supervisor2 which
   lets you set per-application environment variables.  But the app just
   wouldn't start for no reason so I don't know if they were set.  I
   tried launching printenv but it also quit silently -- and without
   printing the environment to the log file.
 
  I had problems getting started with supervisor2 but logs were of great help.
  It can log everything the application-under-run sends to stdout/stderr.
 
  The usual suspects are permissions (are you sure you're starting from
  correct user? that user has permissions to open logfile your app using?) and
  paths.
 
  Max.


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: using buffet

2007-05-24 Thread Shannon -jj Behrens

On 5/23/07, Max Ischenko [EMAIL PROTECTED] wrote:
 On 5/23/07, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
  
 /usr/lib/python2.4/site-packages/Paste-1.3-py2.4.egg/paste/registry.py,
   line 177, in _current_obj
raise TypeError(
TypeError: No object (name: Buffet) has been registered for this thread
  
Same kind of error I got if I run render() in make_app.
 
  I'm sorry, I may have been confused.  I still might be ;)  Can you
  setup a cron job to use wget to access the site and save the generated
  HTML as flat files for use the rest of the time?  Does that make any
  sense, or am I still misunderstanding the problem?

  Well, it may work, thanks for the idea!

  But it's still a hack: I'll have to write a special controller that will
 return the html snippets I need.. Why I can't use Buffet API directly and
 resort to HTTP?

It seems that every framework fails to work very well if you don't at
least pretend to be doing a full request.  I know Aquarium, my
framework, was the same way.  Of course, you don't *actually* need to
use HTTP.  You can use Paste fixture to fake it.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Daemonizing and auto-restart

2007-05-24 Thread Shannon -jj Behrens

On 5/24/07, Ian Bicking [EMAIL PROTECTED] wrote:
 Mike Orr wrote:
  On 5/22/07, Ian Bicking [EMAIL PROTECTED] wrote:
  My other question is, paster has a --monitor-restart option to restart
  the server if it dies.  But the Pylons Cookbook has recipes for
  daemontools and supervisor2.   Are these better than paster's monitor
  for some reason, or are they all interchangeable?
  They all work the same basic way.  paster's is simpler, obviously, since
  it's just one option.  But it hasn't been tested a whole lot, so I
  dunno.  Also it probably has more overhead than daemontools, though I
  don't know if it really is significant.
 
  I looked through supervisor2 and am really impressed with its
  features, but I couldn't get it to run my application and it wouldn't
  say why not.  According to the docs, this happens frequently for a few
  reasons that didn't seem to apply.  I wish it would take more care to
  write a specific error message.

 A good way to use supervisor2 is to write a shell script that you know
 starts your application, and then give that to supervisor2.  If you do,
 be sure you do exec paster ..., as this replaces the shell process
 with the paster process, and signals will be properly sent from
 supervisord to paster.

  I suspect the problem was needing to set the PATH and PYTHONPATH to
  match my workingenv.  I used the beta version of supervisor2 which
  lets you set per-application environment variables.  But the app just
  wouldn't start for no reason so I don't know if they were set.  I
  tried launching printenv but it also quit silently -- and without
  printing the environment to the log file.
 
  Paster with --monitor-restart worked for two days but after I made a
  little change in my application, it got into a curious snit where it
  starts the application successfully but doesn't realize it has, so it
  restarts itself again and again...  The console (Gentoo) says:

 Are you using trunk?  I think this bug was fixed there.

I agree with what Ian said.  I'd also like to add:

* Use su -m theuser to try running the application as the user that
is used in production.  This helps work out a bunch of environmental
difficulties.

* If you're not getting enough logging, and STDOUT and STDERR are
getting swallowed, sometimes it's helpful to output things to a file:

echo Help!  /tmp/web.log
env  /tmp/web.log

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: where to put application init code?

2007-05-23 Thread Shannon -jj Behrens

On 5/22/07, Max Ischenko [EMAIL PROTECTED] wrote:


 On 5/23/07, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
So, any ideas how to detect changes in template files to re-generate
 them
   or at least generate everything at Pylons' application startup?
 
  Perhaps there's something more specific for your situation, but using
  make would do the trick.  Create a run target that depends on the
  files already being generated.  That way, it can re-generate only the
  files that need to be regenerated.

  This may work, running every make php_templates every 15 minutes or so.

  The problem is, how  can I make sure Buffet is inited? I created  an
 extension command registered as paster entry point and running
 render('something.html') results in

 File
 /usr/lib/python2.4/site-packages/PasteScript-1.3.3-py2.4.egg/paste/script/command.py,
 line 210, in run
  result = self.command()
File
 /home/max/projects/dou-trunk/site/doupy/doupy/websetup.py,
 line 275, in command
  render('base/base.html')
File
 /usr/lib/python2.4/site-packages/Pylons-0.9.5-py2.4.egg/pylons/templating.py,
 line 299, in render
  return pylons.buffet.render(template_name=template, fragment=fragment,
File
 /usr/lib/python2.4/site-packages/Paste-1.3-py2.4.egg/paste/registry.py,
 line 125, in __getattr__
  return getattr(self._current_obj(), attr)
File
 /usr/lib/python2.4/site-packages/Paste-1.3-py2.4.egg/paste/registry.py,
 line 177, in _current_obj
  raise TypeError(
  TypeError: No object (name: Buffet) has been registered for this thread

  Same kind of error I got if I run render() in make_app.

I'm sorry, I may have been confused.  I still might be ;)  Can you
setup a cron job to use wget to access the site and save the generated
HTML as flat files for use the rest of the time?  Does that make any
sense, or am I still misunderstanding the problem?

Sorry,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: mako template speed question

2007-05-23 Thread Shannon -jj Behrens

On 5/23/07, voltron [EMAIL PROTECTED] wrote:
 I discovered that I could reduce the number of templates in use by
 using conditionals. Based on the link or the user input, I have a list
 of mako functions that generate HTML Divs of content.

 My question is, is it faster to create a separate template using
 inheritance for each condition or the method of one master template
 with several blocks of content that are rendered conditionally?

 Just curious, thanks

This is probably a matter of engineering taste.  Rendering things
conditionally in a file tens of thousands of lines long will get old
quickly.  I suggest you put performance aside for a moment and just do
whatever makes development easiest.  Personally, I don't mind lots of
little files that rely heavily on inheritance.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Daemonizing and auto-restart

2007-05-22 Thread Shannon -jj Behrens

On 5/22/07, Mike Orr [EMAIL PROTECTED] wrote:
 I'm about to deploy my Pylons application and need to daemonize it and
 set up auto-restart if it dies.  paster serve production.ini start
 does not daemonize it, contrary to what paster serve --help says.
 paster serve --daemon production.ini does, but it does not create a
 PID file so you can't stop it.

 I made my configuration file executable and put this at the top:

 #!/usr/bin/env paster
 [exe]
 command = serve
 daemon = true
 pid_file = %(here)/data/paster.pid
 log_file = %(here)/data/error.log

 I can start it and stop it in daemon mode with ./production.ini
 start and ./production.ini stop, but if I do paster serve
 production.ini start it starts up in normal console mode with logging
 to the console.  Is this a bug in Paste?

 My other question is, paster has a --monitor-restart option to restart
 the server if it dies.  But the Pylons Cookbook has recipes for
 daemontools and supervisor2.   Are these better than paster's monitor
 for some reason, or are they all interchangeable?

I use runit for this because aside from controlling / restarting the
process, it also takes care of log rotation, etc.

YMMV,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: where to put application init code?

2007-05-22 Thread Shannon -jj Behrens

On 5/22/07, Max Ischenko [EMAIL PROTECTED] wrote:
 Hello,

 On 5/18/07, Max Ischenko [EMAIL PROTECTED] wrote:
 
 
   Any other superglobals won't have been setup by then, though. What
   other ones do you need access to?
 
 
  That's precisely the problem.
 
  I have a mixed PHP/Pylons site and wanted to pre-generate some Mako
 templates into HTML/PHP snippets to be included by PHP code. For start, I
 wanted to do that when my Pylons application starts. Of course, being able
 to re-generate them as soon as template in question is changes is even
 better.


  So, any ideas how to detect changes in template files to re-generate them
 or at least generate everything at Pylons' application startup?

Perhaps there's something more specific for your situation, but using
make would do the trick.  Create a run target that depends on the
files already being generated.  That way, it can re-generate only the
files that need to be regenerated.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Common files for a multi-app

2007-05-19 Thread Shannon -jj Behrens

On 5/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I have been working with Pylons and have developed some standalone
 applications that are part of a larger site. I'm trying to find out
 what the best way is to reference common css/javascript files across
 all of the apps. Here is the setup in a nutshell:

 I have a home page and 3 sub-apps that all use the same css layout
 files and some of the same script files. I have so far been putting
 these files in each application's public directory. Bad idea, I know,
 but I was in a hurry. Anyway, the 3 apps really are separate apps and
 I therefore don't really want to put all of them in the same project.
 I currently use paste#urlmap to call out to each separate app.

 Just wondering if anyone has tried to do something similar and found a
 good way to share some of these files across multiple apps.

I have a project called lookandfeel that defines the common look and
feel for all the other Web applications.  In each of the other
applications, in their websetup.py, it calls some setup function from
lookandfeel that creates symlinks.  I use one symlink for the public
directory, and one symlink for the templates directory.  Later, when I
install the apps, I can run paster setup-app myapp, and it'll create
the symlinks.  There's only one gotcha--make sure you create the eggs
from a clean checkout.  Otherwise, the egg creation process will
follow the symlinks, which isn't what you want.

Happy Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [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-19 Thread Shannon -jj Behrens

On 5/17/07, Max Ischenko [EMAIL PROTECTED] wrote:
 On 5/17/07, Shannon -jj Behrens [EMAIL PROTECTED] wrote:
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?
 
  In my own apps, I have a global action results message, but it's
  completely separate FormEncode.

  Er? How's that?

If my common layout, if c.action_results is defined, it gets printed.
That way, any controller can set c.action_results to print out the
message.  If you use session['action_results'] instead, it'll even
survive redirects; just make sure you delete the message from the
session after you show it.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [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-17 Thread Shannon -jj Behrens

By the way, do you know about this trick:

reload(sys)
sys.setdefaultencoding(encoding)

It gets around the site.py problem.

Best Regards,
-jj

On 5/16/07, 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

 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: widgets

2007-05-17 Thread Shannon -jj Behrens

 Please, advise some widget framework to use with Pylons, I know there is
 in turbogears. I'd like to here some recommendations before I start
 learning Toscawidgets because it's only alpha stage now. Maybe there are
 more mature/promising widget frameworks suitable for Pylons.

In the Python world, ToscaWidgets is your only option.  However, if
you forsake the idea of eggifying things, you can just use various
JavaScript widget libraries.  Both Dojo and yui-ext have nice looking
widgets.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Using Mako templates

2007-05-10 Thread Shannon -jj Behrens

On 5/10/07, Christoph Haas [EMAIL PROTECTED] wrote:

 On Wed, May 09, 2007 at 11:18:12AM -0700, KyleJ wrote:
 
  On May 5, 3:08 am, Christoph Haas [EMAIL PROTECTED] wrote:
   tmpl_options['mako.default_filters'] = ['decode.utf8']
 
  You may wish to not use that option.
 
  From the Mako docs ( 
  http://www.makotemplates.org/docs/unicode.html#unicode_handling
  ):
  Note that the built-in decode object is slower than the unicode
  function, since unlike unicode its not a Python builtin, and it also
  checks the type of the incoming data to determine if string conversion
  is needed first.
 
  If you comment that out and you start getting unicode errors, it's
  likely because your strings aren't being converted to unicode objects.

 I had trouble indeed. But I'm willing to come back if that's happening
 again.

  You can either decode them yourself (one variable at a time
  via .decode('utf-8')  ), or you can have request.params output to
  unicode (see 
  http://pylonshq.com/project/pylonshq/browser/Pylons/trunk/docs/internationalization.txt#L516
  ) along with SQLAlchemy (use_unicode=True in either create_engine or
  make_session).

 Where (in a standard Pylons project) would I set use_unicode=True? I
 just found references to create_engine in the websetup.py which is
 obviously not the right place. And my models/__init__.py just has the
 line

 meta = DynamicMetaData()

I fought long and hard with this problem.  Back then, it turned out
that letting SQLAlchemy do the encoding with use_unicode=True wouldn't
work because of a bug in MySQLdb.  However, it looks like that bug has
been fixed in a recent release of MySQLdb.

These days, I bet you can just add ?use_unicode=1 to the end of your
db uri, and it'll work.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Clean url mapping

2007-05-09 Thread Shannon -jj Behrens

On 5/9/07, Graham Higgins [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 On 9 May 2007, at 15:48, voltron wrote:

 
  Oops, those are typos. Just to be sure. I made another quick test:
 
  I cant get this to render:
  http://localhost:5000/test
  I get a 404 error

 Have a look at the docstring in config/routing.py. It sayeth:

 # The more specific and detailed routes should be defined first,
 # so they may take precedent over the more generic routes.

 So, at a guess, you might want to try a re-ordering:

   map.connect('hello1', controller='hello', action='index')
   map.connect('hello2', 'test', controller='hello', action='test')
   map.connect(':controller/:action/:id')
   map.connect('*url', controller='template', action='view')

 (Note, I removed the leading / from /test, going by my own
 routing.py contents)

 HTH

 Cheers,

 Graham.

I'm no Routes expert, but is it really supposed to say:

map.connect('hello2', 'test', controller='hello', action='test')

It seems like 'hello2' shouldn't be there.

-jj
-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Autohandler question

2007-05-09 Thread Shannon -jj Behrens

Since I'm not using Myghty, one of the first things I do when I start
a new project is delete it.

Best Regards,
-jj

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

 Thanks Graham!



 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Apache proxy to pylons link prefix

2007-05-09 Thread Shannon -jj Behrens

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

 I am using Apacher as a proxy server according to this tutorial:

 http://docs.pythonweb.org/display/pylonscookbook/Apache+and+mod_proxy+for+Pylons

 my development.ini conf  has these settings:

 [app:main]
 use = egg:FirstApp
 cache_dir = %(here)s/data
 session_key = firstapp
 session_secret = somesecret
 filter-with = proxy-prefix

 [filter:proxy-prefix]
 use = egg:PasteDeploy#prefix
 prefix = /forms

 I can test this http://test/forms;, and it works, but I don not want
 to have the forms prefix for my pylons links.

 How do I remove this prefix so that I can call my urls without the
 form prefix and at the same time let Apache know to what directory to
 proxy to

There has been a bunch of talk about this recently, because I'm going
through the same thing.  Since this is a Paste issue, let's talk about
it on the Paste mailing list.  I'm right about to post a big ol'
message :)

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: pylons, and executing php or other cgi?

2007-05-08 Thread Shannon -jj Behrens

On 5/8/07, sjol [EMAIL PROTECTED] wrote:
 Hi,

 I've looked for the answer but can't quite figure it out : I would
 like to have the whole website handled by pylons, but I still have
 some php code that is in use and not quite worth the time to translate
 into python. is it possible to have urls handled by routes and when a
 php page is requested execute it ? because of the way it handles
 static files I believe this scenario should be easier than with say
 Django, but I cannot seem to wrrap my head arounbd how I should
 proceed to have this work?!

 any ideas ?

If you're using Apache, you can have one part of the site served by
PHP and another proxied to paster.

Alternatively, Paste has support itself for proxying to another application.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Unicode trouble with formencode, Mako and UTF8

2007-05-08 Thread Shannon -jj Behrens

On 5/8/07, Christoph Haas [EMAIL PROTECTED] wrote:

 Dear list...

 I'm learning how to use Formencode to validate the input of the HTML
 forms I use. Unfortunatly I have some breakage that I don't know how to
 fix.

 My controller:

 ===
 class DhcpZoneForm(formencode.Schema):
 allow_extra_fields = True
 filter_extra_fields = True
 new_network = formencode.validators.URL(not_empty=True)

 class DhcpController(BaseController):
 def new(self):
 return render_response('dhcp/new.mako')

 @validate(schema=DhcpZoneForm, form=u'new')
 def new_form(self):
 return Response('Your network is: %s' %
 self.form_result.get('new_network'))
 ===

 The Mako template is pretty straight forward. Just a HTML form that is
 supposed to call the new_form action with text fields where one field
 is new_network.

 Mako template:
 ===
 # -*- coding: utf-8 -*-
 %inherit file=/base.mako/

 h1New DHCP zone/h1

 ${ h.form(h.url_for(action='new_form')) }
 table
 tr
 thNetwork/th
 td${ h.text_field('new_network') }/td
 /tr
 tr
 thComment/th
 td${ h.text_field('new_comment') }/td
 /tr
 tr
 thStandard Lease Time/th
 td${ h.text_field('new_standard_lease') }/td
 /tr
 /tr
 tr
 thMaximum Lease Time/th
 td${ h.text_field('new_maximum_lease') }/td
 /tr
 /table
 ${ h.submit() }
 /form
 ===

 Now the error that I get is:

 ===
 File 'string', line 1 in lambda
 File '/var/lib/python-support/python2.4/pylons/decorators/__init__.py', line 
 106 in wrapper
   response.content = [htmlfill.render(form_content, params, errors)]
 File '/usr/lib/python2.4/site-packages/formencode/htmlfill.py', line 70 in 
 render
   p.close()
 File '/usr/lib/python2.4/site-packages/formencode/htmlfill.py', line 235 in 
 close
   self._text = ''.join([
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: 
 ordinal not in range(128) the form was passed in as an encoded string, but 
 some data or error messages were unicode strings; the form should be passed 
 in as a unicode string
 ===

 In the debug window I clicked on the '' to see which code broke:

 ===
 try:
 self._text = ''.join([
 t for t in self._content if not isinstance(t, tuple)])
 except UnicodeDecodeError, e:  self._text = ''.join([
 ===

 So I thought it's the self._content that is not correctly encoded in
 unicode and had it print in the debug window. Among many other lines I
 also found parts like these:

 ===
 'li class=navtitel',
 'Host-Eintr\xc3\xa4ge',
 '/li',
 ===

 This is a german text that means 'Host-Einträge'. Shouldn't that string
 rather be u'Host-Einträge'? What have I missed? I told Mako to use UTF8:

 config/environment.py:
 ===
 # The following template options are passed to your template engines
 tmpl_options = {}
 tmpl_options['mako.input_encoding'] = 'UTF-8'
 tmpl_options['mako.output_encoding'] = 'UTF-8'
 tmpl_options['mako.default_filters'] = ['decode.utf8']
 ===

 Help! :)

 Kindly
  Christoph

I've seen this happen on the mailing list a couple times recently, but
since I don't use Mako or htmlfill, I don't remember the answer.  You
may be able to figure out the result by looking in the archives.

Best of Luck,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: difficulties load paste app config

2007-05-08 Thread Shannon -jj Behrens

On 4/17/07, Ian Bicking [EMAIL PROTECTED] wrote:

 Max Ischenko wrote:
File /home/max/projects/dou-trunk/site/doupy/doupy/websetup.py,
  line 54, in command
  app_conf = appconfig('config:'+name, relative_to=conf_dir)
File /usr/lib/python2.4/site-packages/PasteDeploy-1.3-py2.4.egg/
  paste/deploy/loadwsgi.py, line 205, in appconfig
  return context.config()
File /usr/lib/python2.4/site-packages/PasteDeploy-1.3-py2.4.egg/
  paste/deploy/loadwsgi.py, line 609, in config
  conf = AttrDict(self.global_conf)
  TypeError: iteration over non-sequence
 
  I suppose I am doing it in the wrong way. What is a correct way to
  load application's paste config?

 Are you using filter-with?  I've seen problems with that and appconfig,
 but I haven't been able fit it yet.  Using filter-app/next works, though.

Ugh, I just ran into this.  I feel like a car hitting a brick wall ;)

I have the following at the bottom of my .ini:

filter-with = proxy-prefix

[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
force_port =
prefix =

The app works just fine, but paster setup-app doesn't:

paster setup-app acctmgr-staging.ini
debugging: global_conf: None
Traceback (most recent call last):
  File /usr/bin/paster, line 5, in ?
pkg_resources.run_script('PasteScript==1.3.4', 'paster')
  File 
/usr/lib/python2.4/site-packages/setuptools-0.6c3-py2.4.egg/pkg_resources.py,
line 407, in run_script
self.require(requires)[0].run_script(script_name, ns)
  File 
/usr/lib/python2.4/site-packages/setuptools-0.6c3-py2.4.egg/pkg_resources.py,
line 1084, in run_script
execfile(script_filename, namespace, namespace)
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/EGG-INFO/scripts/paster,
line 18, in ?
command.run()
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/paste/script/command.py,
line 76, in run
invoke(command, command_name, options, args[1:])
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/paste/script/command.py,
line 115, in invoke
exit_code = runner.run(args)
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/paste/script/appinstall.py,
line 65, in run
return super(AbstractInstallCommand, self).run(new_args)
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/paste/script/command.py,
line 210, in run
result = self.command()
  File 
/usr/lib/python2.4/site-packages/PasteScript-1.3.4-py2.4.egg/paste/script/appinstall.py,
line 443, in command
conf = appconfig(config_spec, relative_to=os.getcwd())
  File 
/usr/lib/python2.4/site-packages/PasteDeploy-1.3-py2.4.egg/paste/deploy/loadwsgi.py,
line 205, in appconfig
return context.config()
  File 
/usr/lib/python2.4/site-packages/PasteDeploy-1.3-py2.4.egg/paste/deploy/loadwsgi.py,
line 610, in config
conf = AttrDict(self.global_conf)
TypeError: iteration over non-sequence

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Spawning a worker thread from the controller?

2007-05-07 Thread Shannon -jj Behrens

By the way:

http://docs.python.org/lib/module-Queue.html

Best Regards,
-jj

On 5/7/07, Matt Billenstein [EMAIL PROTECTED] wrote:

 Hi Ben,

 I didn't look at it in great detail -- how do you handle passing status
 between the pylons threads and the worker threads?  This seems to be
 where I'm having difficulty.

 thx

 m

 On Mon, May 07, 2007 at 07:16:46PM -, ben adam wrote:
 
  did you look into one of the suggestions posted earlier i.e.
  threadpool ? (works for me).
 
  ben adam
 
  On May 7, 10:10 am, Matt Billenstein [EMAIL PROTECTED] wrote:
   Thanks Ksenia, that's probably the better way to go from what I'm
   learning here.
  
   m
  
  
  
   On Mon, May 07, 2007 at 12:07:16PM +0200, Ksenia Marasanova wrote:
  
Op 4-mei-2007, om 22:53 heeft Matt het volgende geschreven:
  
 Hi, I have a pylons app which I want to spawn a long-running process
 from.  While this process is running (might be an hour or so), I want
 the page that kicked off this process to just display status (maybe
 referesh ever 30 seconds or so)...  Does anyone have some pointers on
 how this should be done or what packages I should be looking into?
  
Just wanted to point to a possible alternative way: I usually save
jobs like this into the database. The cron job checks every X minutes
for a jobs and runs it if needed, changing status to X% completed.
It's pretty easy than to display a progress bar or other status
notifications in the application.
  
Ksenia.
  
   --
   Matt Billenstein
   [EMAIL PROTECTED]://www.vazor.com/
 
 
  

 --
 Matt Billenstein
 [EMAIL PROTECTED]
 http://www.vazor.com/

 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



  1   2   3   >