Re: Feedgenerator development / GeoRSS

2009-12-08 Thread Piotr Kęplicz
Mike Orr, poniedziałek 07 grudnia 2009 22:46:
 I also need GeoRSS, or at least latitude/longitude at the item level.
 I printed out the specs for the two syntaxes, GeoRSS-Simple and
 GeoRSS-GML.  So I need to decide on argument names and data structures
 for Point/Line/Polygon/Box).  Is there a set of standard classes
 somewhere for this?  (Something small and without dependencies.)  Or I
 could just use built-in Python types, though that may be less clear.

Have a look at Python Geo Interface: 
http://trac.gispython.org/lab/wiki/PythonGeoInterface
There's also Shapely, a library used for basic shape operations:
http://gispython.org/shapely/manual.html

.pk.

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: Calling a controllers method from another method? Is there a 'safe' way without redirecting?

2009-12-08 Thread Wichert Akkerman
On 2009-12-7 22:21, Mike Orr wrote:
 On Mon, Dec 7, 2009 at 9:58 AM, Jonathan Vanascojonat...@findmeon.com  
 wrote:
 mike-

 on the subject... does Pylons have a subrequest facility ?

 Some platforms , like mod_perl , offer it:

 http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html

 internal_redirect

 Redirect the current request to some other uri internally

 No.  return self.othermethod() is the equivalent.

I'm quite sure Paste has some API that allows you to do subrequests from 
Pylons. You could look at how middleware such as URLMapper or 
Deliverance handle that.

Wichert.

-- 
Wichert Akkerman wich...@wiggy.net   It is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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.




call setup.py programmatically

2009-12-08 Thread Lea Haensenberger
Hi all,
I'd like to call 'python setup.py extract_messages' within a python
script. Is there a way to do this directly, i.e. not via shell
execution?

Cheers,
Lea

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: Feedgenerator development / GeoRSS

2009-12-08 Thread Mike Orr
2009/12/8 Piotr Kęplicz kepl...@cmc.pl:
 Mike Orr, poniedziałek 07 grudnia 2009 22:46:
 I also need GeoRSS, or at least latitude/longitude at the item level.
 I printed out the specs for the two syntaxes, GeoRSS-Simple and
 GeoRSS-GML.  So I need to decide on argument names and data structures
 for Point/Line/Polygon/Box).  Is there a set of standard classes
 somewhere for this?  (Something small and without dependencies.)  Or I
 could just use built-in Python types, though that may be less clear.

 Have a look at Python Geo Interface:
 http://trac.gispython.org/lab/wiki/PythonGeoInterface
 There's also Shapely, a library used for basic shape operations:
 http://gispython.org/shapely/manual.html

OK. I talked with a GIS consultant yesterday, and he pointed me to
some code in Django for adding location data to newsfeeds.  It ties in
with that callback patch earlier this year, which is extensible for
other kinds of extensions.  So I may just put that all in WebHelpers
under a differerent name, webhelpers.feeds, and let the two
implementations live side by side until we're comfortable retiring
feedgenerator.

-- 
Mike Orr sluggos...@gmail.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-disc...@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: Calling a controllers method from another method? Is there a 'safe' way without redirecting?

2009-12-08 Thread Jonathan Vanasco
First, thanks all.

Subrequests in Apache are weird. IIRC, they appear to be a new request
- but something in mod_perl's request context object will note that it
is a subrequest, and provide a facility to access the 'top level'
context object information.  this is in line with what Shailesh
stated.

Mike-
  you bring up return self.othermethod() as an alternative.
  do you think this would work :
  return OtherController().othermethod()

Wichert-
   Thanks!

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: Calling a controllers method from another method? Is there a 'safe' way without redirecting?

2009-12-08 Thread Mike Orr
On Tue, Dec 8, 2009 at 9:04 AM, Jonathan Vanasco jonat...@findmeon.com wrote:
 First, thanks all.

 Subrequests in Apache are weird. IIRC, they appear to be a new request
 - but something in mod_perl's request context object will note that it
 is a subrequest, and provide a facility to access the 'top level'
 context object information.  this is in line with what Shailesh
 stated.

 Mike-
  you bring up return self.othermethod() as an alternative.
  do you think this would work :
      return OtherController().othermethod()

I'd think so because that's essentially what Pylons does.  But I
vaguely remember that somebody might have had problems with it a year
or two ago.  I'd say try it and see if it does what you expect. You'd
have to supply any arguments the method expects, of course.  Normally
Pylons does this by introspecting the argument names and supplying
them from the routing variables.

Wichert Akkerman wrote:
 I'm quite sure Paste has some API that allows you to do subrequests from 
 Pylons.

Ben might know a way, but I don't.  Although some ideas are below.

 You could look at how middleware such as URLMapper or Deliverance handle that.

Middleware are in a different situation.  They have the application
(the next middleware) and call it in the WSGI manner.  So they can
call it on their own URLs instead of the original URL.

But that brings up something that occurred to me this morning.  If you
have the PylonsApp instance, you can call it as a WSGI application
too.But I don't know where you'd get the pylonsapp from because I
don't see it in 'config' or 'request.environ'.  You could
reinstantiate it by calling make_app() with full_stack=False, and then
call it.  I'm not sure if the Pylons globals would be overwritten, but
as long as you don't use them for anything else after calling the app,
it wouldn't matter.

So the action would look something like this:

# Untested
def subrequesting_action(self, environ, start_response):
sub_environ = environ.copy()
sub_environ[PATH_INFO] = /other_url
sub_environ[REQUEST_METHOD] = GET
sub_environ[QUERY_STRING] = 
sub_environ[wsgi.input] = StringIO(, r)
return pylonsapp(sub_environ, start_response)

Or using WebOb:

# Untested
def subrequesting_action(self):
req = webob.Request.blank(/other_url)
return req.get_response(pylonsapp)

The latter would create a new 'environ' and 'start_response' rather
than using the one supplied by Pylons.  I think that's OK but I'm not
100% sure.

There is a 'forward' function in pylons.controllers.util, but it seems
more geared toward calling external WSGI applications, and you would
have to modify request.environ to set the URL, so I'm not sure how
practical it would be in this case.

-- 
Mike Orr sluggos...@gmail.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-disc...@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.




Can't get pylons to log in mod_python mode..

2009-12-08 Thread D D
Hi,
I have a pylons app, and everything works fine with running via Paster
serve.
However, I have deployed it using mod_python, and I am not able to get it to
print any logs anywhere.

I don't get any logs in chainsaw, console (apache's error_log) or in the
specified log file (/var/log/mysite.log). This only happens when I run it
via mod_python, everything works fine while running through paster serve.
I do get exceptions in apache error_log when there is an exception/crash for
the site.

Below are the relevant parts for logging:

# Logging configuration
[loggers]
keys = root, routes, mysite, sqlalchemy, mako, secure

[handlers]
keys = console, chainsaw, mysitelog

[formatters]
keys = generic, xmllayout

[logger_root]
level = DEBUG
handlers = console, chainsaw, mysitelog

[logger_routes]
level = INFO
handlers =
qualname = routes.middleware

[logger_mysite]
level = DEBUG
handlers =
qualname = mysite

[logger_sqlalchemy]
level = DEBUG
handlers =
qualname = sqlalchemy.engine

[logger_mako]
level = DEBUG
handlers =
qualname = pylons.templating

[logger_secure]
level = DEBUG
handlers =
qualname = pylons.decorators.secure


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

[handler_chainsaw]
class = xmllayout.RawSocketHandler
args = ('localhost', 4445)
level = NOTSET
formatter = xmllayout

[handler_mysitelog]
class = FileHandler
args = ('/var/log/mysite.log','a')
level = DEBUG
formatter = generic

[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

[formatter_xmllayout]
class = xmllayout.XMLLayout


Any suggestions on where to start debugging this? I am generally pretty new
to mod_python, so any pointers will help.
Thanks,
DD.

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: WebHelpers issues

2009-12-08 Thread Ben Bangert
On Dec 3, 2009, at 12:34 AM, Mike Orr wrote:

 I upgraded Markdown to 1.7 last year, and now it's at 2.0.
 
 Deprecated webhelpers.markdown.  Users can install Markdown or the
 alternate Markdown2 in PyPI.

Why not leave it as is, but have it attempt to import the full Markdown 2.0 if 
its around? That way you get Markdown 1.7 for free with WH, but if you really 
want 2.0, you install it yourself. A simple try/except for the import at the 
top should work fine.

Cheers,
Ben

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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.




Adding keys to request.params [was: Re: Calling a controllers method from another method? Is there a 'safe' way without redirecting?]

2009-12-08 Thread Shailesh Kochhar
Shailesh Kochhar wrote:
 Mike Orr wrote:
 On Mon, Dec 7, 2009 at 9:58 AM, Jonathan Vanasco 
 jonat...@findmeon.com wrote:
 mike-

 on the subject... does Pylons have a subrequest facility ?

 Some platforms , like mod_perl , offer it:

 http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html

 internal_redirect

 Redirect the current request to some other uri internally

 No.  return self.othermethod() is the equivalent.
 
 Since the pylons Request and Response objects are thread locals, 
 self.othermethod() isn't an exact equivalent of a sub-request. The 
 application will still reference the existing Request object. If the 
 request parameters need to be changed, you'll need to do that before 
 calling self.othermethod().
 
 I'm not sure how StackedObjectProxy works but perhaps a new Request 
 could be pushed on-top of the current one?

I tried updating request.params in one of my apps without much success. Turns 
out that request.params is dynamically generated from request.GET and 
request.POST. If you're trying to update request.params before redirecting to 
another method, you'll need to update one of the two.

Best,
   - Shailesh

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: Can't get pylons to log in mod_python mode..

2009-12-08 Thread Graham Dumpleton
Paste server does special stuff to initialise the environment for
logging. Arguably it shouldn't do this and any such initialisation
should be a side effect of getting the root WSGI application object.

What it means is that you have to perform the same initialisation
somehow when using mod_python.

For discussion of how to do that for mod_wsgi see:

http://groups.google.com/group/pylons-discuss/browse_thread/thread/9b9add4529b3779c

You will have to work out how to do the same for mod_python.

Graham

On Dec 9, 7:20 am, D D d2n...@gmail.com wrote:
 Hi,
 I have a pylons app, and everything works fine with running via Paster
 serve.
 However, I have deployed it using mod_python, and I am not able to get it to
 print any logs anywhere.

 I don't get any logs in chainsaw, console (apache's error_log) or in the
 specified log file (/var/log/mysite.log). This only happens when I run it
 via mod_python, everything works fine while running through paster serve.
 I do get exceptions in apache error_log when there is an exception/crash for
 the site.

 Below are the relevant parts for logging:

 # Logging configuration
 [loggers]
 keys = root, routes, mysite, sqlalchemy, mako, secure

 [handlers]
 keys = console, chainsaw, mysitelog

 [formatters]
 keys = generic, xmllayout

 [logger_root]
 level = DEBUG
 handlers = console, chainsaw, mysitelog

 [logger_routes]
 level = INFO
 handlers =
 qualname = routes.middleware

 [logger_mysite]
 level = DEBUG
 handlers =
 qualname = mysite

 [logger_sqlalchemy]
 level = DEBUG
 handlers =
 qualname = sqlalchemy.engine

 [logger_mako]
 level = DEBUG
 handlers =
 qualname = pylons.templating

 [logger_secure]
 level = DEBUG
 handlers =
 qualname = pylons.decorators.secure

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

 [handler_chainsaw]
 class = xmllayout.RawSocketHandler
 args = ('localhost', 4445)
 level = NOTSET
 formatter = xmllayout

 [handler_mysitelog]
 class = FileHandler
 args = ('/var/log/mysite.log','a')
 level = DEBUG
 formatter = generic

 [formatter_generic]
 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
 datefmt = %H:%M:%S

 [formatter_xmllayout]
 class = xmllayout.XMLLayout

 Any suggestions on where to start debugging this? I am generally pretty new
 to mod_python, so any pointers will help.
 Thanks,
 DD.

--

You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-disc...@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: WebHelpers issues

2009-12-08 Thread Mike Orr
On Tue, Dec 8, 2009 at 1:06 PM, Ben Bangert b...@groovie.org wrote:
 On Dec 3, 2009, at 12:34 AM, Mike Orr wrote:

 I upgraded Markdown to 1.7 last year, and now it's at 2.0.

 Deprecated webhelpers.markdown.  Users can install Markdown or the
 alternate Markdown2 in PyPI.

 Why not leave it as is, but have it attempt to import the full Markdown 2.0 
 if its around? That way you get Markdown 1.7 for free with WH, but if you 
 really want 2.0, you install it yourself. A simple try/except for the import 
 at the top should work fine.

That is what it does, as the next paragraph tried to explain.


 Added a 'markdown' argument to
``webhelpers.html.converters.markdown()`` to specify the
implementation module.  If none is specified, it will try to import
``markdown``, or else fall back to ``webhelpers.markdown`` (with a
deprecation warning.)

If you think 1.7 should not be deprecated, I can take off the
deprecation warning. But I'm a bit leery of saying you'll roll the
dice and get one version or another depending on whether a package is
properly in the Python path, without telling you which one you're
getting.  Because sometimes Setuptools finds things in unexpected
places, or doesn't find things you've installed.

As long as the two versions are completely compatible and have the
same behavior, it doesn't matter.  But I notice that Markdown 1.7 adds
extra spaces and newlines that Markdown 2 doesn't, so I had to make
version-specific results for the test suite.  Who knows what other
differences might appear later.  At minimum, Markdown 2 has extensions
that Markdown 1.7 doesn't have, which would cause errors if WH falls
back to the built-in one.

BTW, I need your input on the feedgenerator  GIS issues in the other
WebHelpers threads.

-- 
Mike Orr sluggos...@gmail.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-disc...@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.