[pylons-devel] Re: request context for Sentry

2016-03-19 Thread Jonathan Vanasco


On Wednesday, March 16, 2016 at 9:36:44 PM UTC-4, Zsolt Ero wrote:
>
> David Cramer from Sentry replied to me that if Sentry is used with the 
> middleware, then it should automatically receive the WSGI context:
> from sentry.middleware import Sentry
>
> application = Sentry(application, client=Client(dsn, ...))
>
> My problem is that in Pyramid I have no idea where could I get an 
> application, or if this would work at all.
>

That looks like the initial app setup in your `project/__init__.py`

`application` would be what is returned from config.make_wsgi_app()

Some people do "return config.make_wsgi_app()"

Others prefer "app = config.make_wsgi_app()", then wrap it in middleware


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


[pylons-devel] ANN: zerodb Google Hangout on March 22nd. End-to-end DB encryption

2016-03-19 Thread MacLane & Michael
The ZeroDB team will be hosting a Community Google Hangout on March 22, 
2016.

ZeroDB --- an end-to-end encrypted database based on ZODB & written in 
Python.
== 

1) Introduction to ZeroDB Founders & Developer community

2) Recap of the latest ZeroDB releases and developer contributions

3) Q&A from the community with invitation to join & explore various
developer projects

RSVP Here:
https://plus.google.com/u/0/events/c2u3fcer2rtfq2puj91mdks2q70

---

Some ZeroDB Resources:

Documentation: https://docs.zerodb.io/

Blog:  https://medium.com/@ZeroDB_

Slack: https://slack.zerodb.io/

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


[pylons-devel] request context for Sentry

2016-03-19 Thread Zsolt Ero
I'm using Sentry with Pyramid, as per their official .ini config notes:
https://docs.getsentry.com/hosted/clients/python/integrations/pyramid/

This way, if there is ever an Internal Server Error page, I get a full 
stack-trace submitted to Sentry as well as a request which can be replayed 
or converted to curl command line. Super life-saver when trying to debug 
hard-to-reproduce bugs.

My problem is that obviously I don't want the user to see an Internal 
Server Error page, so I put all critical functions in try-except blocks.

When using a try-except block Sentry has a captureException method, which 
submits that stack-trace to Sentry.
https://docs.getsentry.com/hosted/clients/python/usage/

My problem is that when using this captureException, the request parameters 
are not submitted, only the stack-trace, so the exception cannot be 
replayed / curl-ed this way.

David Cramer from Sentry replied to me that if Sentry is used with the 
middleware, then it should automatically receive the WSGI context:
from sentry.middleware import Sentry

application = Sentry(application, client=Client(dsn, ...))

My problem is that in Pyramid I have no idea where could I get an 
application, or if this would work at all.

There is a pyramid-raven library, which I believe does what I'd need to 
attach the http context, but it's not using an application but a manually 
created http data dict.
https://github.com/thruflo/pyramid_raven/blob/bb4bb5227b9c40efec71238b4ee452db01921d45/src/pyramid_raven/client.py#L103

What is the recommended way to Pyramid to get this context? Are any of you 
using Sentry with a wrapper for captureException?  

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


[pylons-devel] Re: request context for Sentry

2016-03-19 Thread Zsolt Ero
Thanks, I see. I believe this way I do not need the .ini part, do I?

On Thursday, March 17, 2016 at 3:40:28 AM UTC+1, Jonathan Vanasco wrote:
>
>
>
> On Wednesday, March 16, 2016 at 9:36:44 PM UTC-4, Zsolt Ero wrote:
>>
>> David Cramer from Sentry replied to me that if Sentry is used with the 
>> middleware, then it should automatically receive the WSGI context:
>> from sentry.middleware import Sentry
>>
>> application = Sentry(application, client=Client(dsn, ...))
>>
>> My problem is that in Pyramid I have no idea where could I get an 
>> application, or if this would work at all.
>>
>
> That looks like the initial app setup in your `project/__init__.py`
>
> `application` would be what is returned from config.make_wsgi_app()
>
> Some people do "return config.make_wsgi_app()"
>
> Others prefer "app = config.make_wsgi_app()", then wrap it in middleware
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-devel] Setting translogger format via ini

2016-03-19 Thread Zsolt Ero
Thanks a lot for this, I'll have a look how to use tweens, as I haven't 
been using them so far, but looks clean, I'll try to integrate it.


On Saturday, March 12, 2016 at 4:04:47 AM UTC+1, Mike Orr wrote:
>
> Here's the code. You can see it's short and simple; half the code is 
> just to make it more configurable. Usage: 
>
> pyramid_includes = accesslog 
>
> # Settings, all optional 
> access.format = {response.status_int} {request.method} {request.path_qs} 
> access.ignore =  /fanstatic /_debug_toolbar 
> access.ignore_usual = true 
>
>
>
> On Thu, Mar 10, 2016 at 6:46 PM, Mike Orr  > wrote: 
> > On Thu, Mar 10, 2016 at 3:32 AM, Zsolt Ero  > wrote: 
> >> Hi, 
> >> 
> >> My first mailing list post, as this really puzzles me. I'd like to use 
> a 
> >> short format for displaying HTTP requests in development mode. 
> >> 
> >> Before, I used to have this snippet in my Pyramid app's __init__.py: 
> >> 
> >> from paste.translogger import TransLogger 
> >> format = '%(status)s %(REQUEST_METHOD)s %(REQUEST_URI)s' 
> >> app = TransLogger(app, format=format) 
> >> return app 
> >> 
> >> 
> >> I'd like to turn this into using an .ini file, however, I cannot 
> specify the 
> >> format, as the .ini file syntax needs some kind of escaping, which I 
> cannot 
> >> figure out. 
> >> 
> >> Here is a try on setting translogger format via .ini file: 
> >> 
> >> [filter:translogger] 
> >> use = egg:Paste#translogger 
> >> setup_console_handler = False 
> >> format = %%(status)s %%(REQUEST_METHOD)s %%(REQUEST_URI)s 
> >> 
> >> 
> >> 
> >> It results in an error: 
> >> 
> >> ConfigParser.InterpolationMissingOptionError: Error in file 
> >> .../development.ini: Bad value substitution: 
> >>  section: [filter:translogger] 
> >>  option : format 
> >>  key : status 
> >>  rawval : %%(status)s 
> >> 
> >> 
> >> What is the right escaping method to set translogger's format via .ini 
> file? 
> >> 
> >> Or if it's not possible to escape it, then I don't get it. Why does 
> >> translogger has a format option, if you cannot actually enter anything 
> there 
> >> via ini? 
> >> 
> >> Alembic, for example supports escaping perfectly fine, for example: 
> >> 
> >> file_template = 
> >> 
> %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d_%%(minute).2d_%%(second).2d_%%(rev)s
>  
>
> >> 
> >> 
> >> Here is this 4 year old issue in PasteDeploy, I think it's related: 
> >> 
> >> 
> https://bitbucket.org/ianb/pastedeploy/issues/11/there-is-no-way-to-escape-character-in-the
>  
> >> 
> >> Any ideas how to solve this? 
> > 
> > I didn't like using middleware so I made a Pyramid tween that logs 
> > requests. I don't have the code with me but I can get it tomorrow. 
> > After calling the applicaiton I make a log message based on the 
> > response and request. I probably bypassed the % parsing problem by 
> > using str.format instead, so that I could override the format. My 
> > logger is called 'access'. 
> > 
> > 
> > -- 
> > Mike Orr > 
>
>
>
> -- 
> Mike Orr > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


[pylons-devel] Re: request context for Sentry

2016-03-19 Thread Zsolt Ero
Thanks, I was able to make a working client, but not using the pipeline + 
filter part in the ini, but by wrapping app by:

from raven import Client

from raven.middleware import Sentry

client = Client('https://...:...@app.getsentry.com/ 
...')

app = Sentry(app, client=client)

This way client is configured on init and captureException works 
automatically. 




Friday, March 18, 2016 at 1:26:39 AM UTC+1, Zsolt Ero wrote:
>
> Thanks, I see. I believe this way I do not need the .ini part, do I?
>
> On Thursday, March 17, 2016 at 3:40:28 AM UTC+1, Jonathan Vanasco wrote:
>>
>>
>>
>> On Wednesday, March 16, 2016 at 9:36:44 PM UTC-4, Zsolt Ero wrote:
>>>
>>> David Cramer from Sentry replied to me that if Sentry is used with the 
>>> middleware, then it should automatically receive the WSGI context:
>>> from sentry.middleware import Sentry
>>>
>>> application = Sentry(application, client=Client(dsn, ...))
>>>
>>> My problem is that in Pyramid I have no idea where could I get an 
>>> application, or if this would work at all.
>>>
>>
>> That looks like the initial app setup in your `project/__init__.py`
>>
>> `application` would be what is returned from config.make_wsgi_app()
>>
>> Some people do "return config.make_wsgi_app()"
>>
>> Others prefer "app = config.make_wsgi_app()", then wrap it in middleware
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-devel] Re: request context for Sentry

2016-03-19 Thread Michael Merickel
I'm missing something here probably but the raven docs have pretty
straightforward support for configuring it via the ini file. Have you tried
this?

https://docs.getsentry.com/hosted/clients/python/integrations/pyramid/#pastedeploy-filter

On Sat, Mar 19, 2016 at 5:44 PM, Zsolt Ero  wrote:

> Thanks, I was able to make a working client, but not using the pipeline +
> filter part in the ini, but by wrapping app by:
>
> from raven import Client
>
> from raven.middleware import Sentry
>
> client = Client('https://...:...@app.getsentry.com/
> ...')
>
> app = Sentry(app, client=client)
>
> This way client is configured on init and captureException works
> automatically.
>
>
>
>
> Friday, March 18, 2016 at 1:26:39 AM UTC+1, Zsolt Ero wrote:
>>
>> Thanks, I see. I believe this way I do not need the .ini part, do I?
>>
>> On Thursday, March 17, 2016 at 3:40:28 AM UTC+1, Jonathan Vanasco wrote:
>>>
>>>
>>>
>>> On Wednesday, March 16, 2016 at 9:36:44 PM UTC-4, Zsolt Ero wrote:

 David Cramer from Sentry replied to me that if Sentry is used with the
 middleware, then it should automatically receive the WSGI context:
 from sentry.middleware import Sentry

 application = Sentry(application, client=Client(dsn, ...))

 My problem is that in Pyramid I have no idea where could I get an
 application, or if this would work at all.

>>>
>>> That looks like the initial app setup in your `project/__init__.py`
>>>
>>> `application` would be what is returned from config.make_wsgi_app()
>>>
>>> Some people do "return config.make_wsgi_app()"
>>>
>>> Others prefer "app = config.make_wsgi_app()", then wrap it in middleware
>>>
>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/pylons-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-devel] Re: request context for Sentry

2016-03-19 Thread Zsolt Ero
Yes, that is how I started. The problem is with client.captureException().

The problem is that there is no way to get the Client when it's
configured via ini (or at least I have no idea how to get it).

So when configured via ini, Sentry can only provide HTTP context for
uncaught exceptions which results in an Internal Server Error.

Obviously, your web app shouldn't result in Internal Server Errors,
but would try to give a reasonable error message, and internally log
the problem, so critical parts are in try-except blocks, and this is
where client.captureException() is used.

try:
...
except Exception:
   client.captureException()

Now this client needs to be configured via a Sentry __call__, or else,
the http context is missing. That's why I needed to use the python
config vay.

On 20 March 2016 at 01:00, Michael Merickel  wrote:
> I'm missing something here probably but the raven docs have pretty
> straightforward support for configuring it via the ini file. Have you tried
> this?
>
> https://docs.getsentry.com/hosted/clients/python/integrations/pyramid/#pastedeploy-filter
>
> On Sat, Mar 19, 2016 at 5:44 PM, Zsolt Ero  wrote:
>>
>> Thanks, I was able to make a working client, but not using the pipeline +
>> filter part in the ini, but by wrapping app by:
>>
>> from raven import Client
>>
>> from raven.middleware import Sentry
>>
>>
>> client = Client('https://...:...@app.getsentry.com/...')
>>
>> app = Sentry(app, client=client)
>>
>>
>> This way client is configured on init and captureException works
>> automatically.
>>
>>
>>
>>
>> Friday, March 18, 2016 at 1:26:39 AM UTC+1, Zsolt Ero wrote:
>>>
>>> Thanks, I see. I believe this way I do not need the .ini part, do I?
>>>
>>> On Thursday, March 17, 2016 at 3:40:28 AM UTC+1, Jonathan Vanasco wrote:



 On Wednesday, March 16, 2016 at 9:36:44 PM UTC-4, Zsolt Ero wrote:
>
> David Cramer from Sentry replied to me that if Sentry is used with the
> middleware, then it should automatically receive the WSGI context:
> from sentry.middleware import Sentry
>
> application = Sentry(application, client=Client(dsn, ...))
>
> My problem is that in Pyramid I have no idea where could I get an
> application, or if this would work at all.


 That looks like the initial app setup in your `project/__init__.py`

 `application` would be what is returned from config.make_wsgi_app()

 Some people do "return config.make_wsgi_app()"

 Others prefer "app = config.make_wsgi_app()", then wrap it in middleware


>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-devel+unsubscr...@googlegroups.com.
>> To post to this group, send email to pylons-devel@googlegroups.com.
>> Visit this group at https://groups.google.com/group/pylons-devel.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pylons-devel" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pylons-devel/ou3XQ6OC4OQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pylons-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/pylons-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-devel+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-devel.
For more options, visit https://groups.google.com/d/optout.