[web2py] Re: Web2py Integration with Sentry

2016-01-20 Thread James Q
Sorry, I ended up not using web2py so I never got to this :(

On Monday, January 6, 2014 at 10:14:46 PM UTC-5, James Q wrote:
>
> Has anyone ever integrated web2py an Sentry (
> https://github.com/getsentry/sentry)? I would like it if all web2py 
> generated exceptions generate a ticket like usual, but also generates an 
> event to a sentry server. Has anyone ever done this? If not, could anyone 
> point to where I would need to patch web2py or how best this integration 
> would work?
>
> Thanks for any help!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Web2py Integration with Multiple Oauth Logins

2014-02-23 Thread James Q
Hello again,

Thanks for taking your time to engage with me. Hopefully I can get this
working sometime soon.

Regarding the update, I re-cloned the repository and notied a w2p file
there. I used this file to upload to the web2py admin interface, which
gives me the same error as before. Are you saying that I need to extract it
first, add my keys to it, and then try uploading it?

Either way, I did it manually using tar and I get this traceback now, which
is similar to the above:

Traceback (most recent call last):
  File "/home/james/Development/web2py/gluon/restricted.py", line 217,
in restricted
exec ccode in environment
  File 
"/home/james/Development/web2py/applications/oauth/models/plugin_social_auth.py"
<http://127.0.0.1/admin/edit/oauth/models/plugin_social_auth.py>, line
7, in 
Field('user', 'reference auth_user', writable=False, notnull=True))
  File "/home/james/Development/web2py/gluon/dal.py", line 8139, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File "/home/james/Development/web2py/gluon/dal.py", line 8156, in
lazy_define_table
table = table_class(self, tablename, *fields, **args)
  File "/home/james/Development/web2py/gluon/dal.py", line 8665, in __init__
check_reserved(field_name)
  File "/home/james/Development/web2py/gluon/dal.py", line 7850, in
check_reserved_keyword
'invalid table/column name "%s" is a "%s" reserved SQL/NOSQL
keyword' % (name, backend.upper()))
SyntaxError: invalid table/column name "user" is a "ALL" reserved
SQL/NOSQL keyword


Guess that needs to be changed as well :)

-- James


On Sat, Feb 22, 2014 at 3:41 AM, Quint  wrote:

> Hi,
>
> About the exception:
>
> I changed the Field name to "oauth_uid".
> I did not notice this problem because i'm using GAE.
>
> About "*App does not exist or you are not authorized*":
>
> This means that your oauth key/secret is not properly set in your
> configuration.
> You are not supplying a valid/authorized oauth client key to the provider.
> Which provider is giving this message?
> What does your configuration look like?
>
> What is find strange is that that plugin packed/installed by yourself is
> giving different result than te one installed manually. This should be
> exactly the same right? Are you sure everything is included in the one
> packed by yourself?
>
> Regards,
>
> Quint
>
>
> On Saturday, February 22, 2014 4:15:11 AM UTC+1, James Q wrote:
>>
>> Interesting plugin, thanks for the link.
>>
>> I took that repository, tar'ed and gzip'ed it, and uploaded it as a
>> plugin. Says "App does not exist or you are not authorized". No idea what
>> that means, so I did it manually in a new app called oauth. Here is what I
>> get as an exception when trying to open up the new app:
>>
>> Traceback (most recent call last):
>>   File "/home/james/Development/web2py/gluon/restricted.py", line 217, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/james/Development/deemok-web2py/applications/oauth/models/plugin_social_auth.py"
>>  <http://127.0.0.1/admin/edit/oauth/models/plugin_social_auth.py>, line 7, 
>> in 
>> Field('user', 'reference auth_user', writable=False, notnull=True))
>>   File "/home/james/Development/web2py/gluon/dal.py", line 8139, in 
>> define_table
>> table = self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/james/Development/web2py/gluon/dal.py", line 8156, in 
>> lazy_define_table
>> table = table_class(self, tablename, *fields, **args)
>>   File "/home/james/Development/web2py/gluon/dal.py", line 8665, in __init__
>> check_reserved(field_name)  File 
>> "/home/james/Development/web2py/gluon/dal.py", line 7850, in 
>> check_reserved_keyword
>> 'invalid table/column name "%s" is a "%s" reserved SQL/NOSQL keyword' % 
>> (name, backend.upper()))
>> SyntaxError: invalid table/column name "uid" is a "ALL" reserved SQL/NOSQL 
>> keyword
>>
>> Can you possibly rename the field:
>>
>> Field('uid', 'string', notnull=True, writable=False, length=255),
>>
>> to:
>>
>> Field('oauth_uid', 'string', notnull=True, writable=False, length=255),
>>
>> Or something along those lines?
>>
>>
>>
>>
>>
>> On Friday, February 21, 2014 3:55:00 AM UTC-5, Quint wrote:
>>>
>>> Hi,
>>>
>>>

[web2py] Re: Web2py Integration with Multiple Oauth Logins

2014-02-21 Thread James Q
Interesting plugin, thanks for the link. 

I took that repository, tar'ed and gzip'ed it, and uploaded it as a plugin. 
Says "App does not exist or you are not authorized". No idea what that 
means, so I did it manually in a new app called oauth. Here is what I get 
as an exception when trying to open up the new app:

Traceback (most recent call last):
  File "/home/james/Development/web2py/gluon/restricted.py", line 217, in 
restricted
exec ccode in environment
  File 
"/home/james/Development/deemok-web2py/applications/oauth/models/plugin_social_auth.py"
 <http://127.0.0.1/admin/edit/oauth/models/plugin_social_auth.py>, line 7, in 

Field('user', 'reference auth_user', writable=False, notnull=True))
  File "/home/james/Development/web2py/gluon/dal.py", line 8139, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File "/home/james/Development/web2py/gluon/dal.py", line 8156, in 
lazy_define_table
table = table_class(self, tablename, *fields, **args)
  File "/home/james/Development/web2py/gluon/dal.py", line 8665, in __init__
check_reserved(field_name)  File 
"/home/james/Development/web2py/gluon/dal.py", line 7850, in 
check_reserved_keyword
'invalid table/column name "%s" is a "%s" reserved SQL/NOSQL keyword' % 
(name, backend.upper()))
SyntaxError: invalid table/column name "uid" is a "ALL" reserved SQL/NOSQL 
keyword

Can you possibly rename the field:

Field('uid', 'string', notnull=True, writable=False, length=255),

to:

Field('oauth_uid', 'string', notnull=True, writable=False, length=255),

Or something along those lines?





On Friday, February 21, 2014 3:55:00 AM UTC-5, Quint wrote:
>
> Hi,
>  
> You could have a look at 
> python-social-auth<https://github.com/omab/python-social-auth> and 
> if you like it and don't know how to integrate it, have a look at this 
> plugin <https://code.google.com/p/w2p-social-auth/> to integrate it in 
> web2py.
>  
>  
> Quint
>
> On Wednesday, February 19, 2014 12:33:29 AM UTC+1, James Q wrote:
>
>> I have a feeling that this topic comes up often, but I cannot seem to 
>> Google a good solution to this. Essentially, I want users to be able to 
>> login using either the built in Auth, or login via some Oauth provider, 
>> like Twitter and Facebook. I have seen previous solutions using 
>> ExtendedLoginForm and custom Twitter classes that inherit from 
>> OAuthProvider, but they no longer seem to work. The Twitter code I find no 
>> longer supports the newest Twitter API; the linkedin code from the web2py 
>> book also  does not work.
>>
>> Here is sample code I have now, which only seems to constantly redirect 
>> me to the logout page:
>>
>> 1) Created new web2py application by copying the welcome one to a folder 
>> named 'oauth'
>> 2) Added this code to db.py (taken from multiple examples online):
>>
>> from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
>> from oauth2 import Client, Consumer, Token
>>
>> class TwitterAccount(OAuthAccount):
>> AUTH_URL = "http://twitter.com/oauth/authorize";
>> TOKEN_URL = "https://twitter.com/oauth/request_token";
>> ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token";
>> CLIENT_ID = "..."
>> CLIENT_SECRET = "..."
>>
>> def __init__(self, g):
>> OAuthAccount.__init__(self, g, self.CLIENT_ID, 
>> self.CLIENT_SECRET, self.AUTH_URL, self.TOKEN_URL, self.ACCESS_TOKEN_URL)
>>
>> def get_user(self):
>> if self.accessToken() is not None:
>> consumer = Consumer(key=self.CLIENT_ID, 
>> secret=self.CLIENT_SECRET)
>> client = Client(consumer, self.accessToken())
>> resp, content = client.request('
>> http://api.twitter.com/1/account/verify_credentials.json')
>> if resp['status'] != '200':
>> # cannot get user info. should check status
>> #redirect("http://google.com";)
>> return None
>> u = json.loads(content)
>> return dict(first_name = u['name'], 
>> username=u['screen_name'], name=u['name'], registration_id=u['id'])
>>
>> auth.settings.login_form=TwitterAccount(g=globals())
>>
>> 3) Going to 127.0.0.1/oauth/user/login redirects me to user/logout.
>>
>>
>> Besides my frustration in trying to find timely information about this, 
>> is there working code out there that is *recent*, in that it works with 
>> latest web2py and the latest Oauth implementations? I'd really appreciate 
>> any tips or hints anyone has.
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Web2py Integration with Multiple Oauth Logins

2014-02-18 Thread James Q
I have a feeling that this topic comes up often, but I cannot seem to 
Google a good solution to this. Essentially, I want users to be able to 
login using either the built in Auth, or login via some Oauth provider, 
like Twitter and Facebook. I have seen previous solutions using 
ExtendedLoginForm and custom Twitter classes that inherit from 
OAuthProvider, but they no longer seem to work. The Twitter code I find no 
longer supports the newest Twitter API; the linkedin code from the web2py 
book also  does not work.

Here is sample code I have now, which only seems to constantly redirect me 
to the logout page:

1) Created new web2py application by copying the welcome one to a folder 
named 'oauth'
2) Added this code to db.py (taken from multiple examples online):

from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
from oauth2 import Client, Consumer, Token

class TwitterAccount(OAuthAccount):
AUTH_URL = "http://twitter.com/oauth/authorize";
TOKEN_URL = "https://twitter.com/oauth/request_token";
ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token";
CLIENT_ID = "..."
CLIENT_SECRET = "..."

def __init__(self, g):
OAuthAccount.__init__(self, g, self.CLIENT_ID, self.CLIENT_SECRET, 
self.AUTH_URL, self.TOKEN_URL, self.ACCESS_TOKEN_URL)

def get_user(self):
if self.accessToken() is not None:
consumer = Consumer(key=self.CLIENT_ID, 
secret=self.CLIENT_SECRET)
client = Client(consumer, self.accessToken())
resp, content = 
client.request('http://api.twitter.com/1/account/verify_credentials.json')
if resp['status'] != '200':
# cannot get user info. should check status
#redirect("http://google.com";)
return None
u = json.loads(content)
return dict(first_name = u['name'], username=u['screen_name'], 
name=u['name'], registration_id=u['id'])

auth.settings.login_form=TwitterAccount(g=globals())

3) Going to 127.0.0.1/oauth/user/login redirects me to user/logout.


Besides my frustration in trying to find timely information about this, is 
there working code out there that is *recent*, in that it works with latest 
web2py and the latest Oauth implementations? I'd really appreciate any tips 
or hints anyone has.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Web2py Integration with Sentry

2014-01-16 Thread James Q
Great. I won't be able to get to this soon, but I assume the standard
process: git clone, make change and make a pull request?

-- james
On Jan 15, 2014 12:17 PM, "Massimo Di Pierro" 
wrote:

> Always. :-)
>
> Rules are simple. I always take a patch if:
> 1) fixes a security issue OR
> 2) does not break backward compatibility AND
> 3) makes web2py faster OR
> 4) add a new functionality without making previous behavior slower
>
> On Wednesday, 15 January 2014 00:41:54 UTC-6, James Q wrote:
>>
>> Massimo: Would you consider taking a patch / pull request for a new
>> script?
>>
>> -- James
>>
>> On Thursday, January 9, 2014 9:16:02 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> The problem is that it would not work. you can have exceptions at two
>>> levels: web2py apps, web2py itself. In other frameworks these two levels
>>> are mixed up so sentry will catch either exceptions. In web2py the two
>>> levels are well separated and web2py catches app exceptions before they
>>> propagate up and sentry would not catch them. sentry would only catch
>>> exceptions in web2py itself and that is pretty much useless.
>>>
>>> You can think about it in another way, web2py already has a mechanism to
>>> catch exceptions and log them. and you cannot do:
>>>
>>> try:
>>> try:
>>>   do something
>>>exceptiion:
>>>   web2py ticket system
>>> except:
>>>sentry logging system
>>>
>>> and expect the second except to catch anything. Look instead into
>>> scritps/tickets2db.py and scripts/tickets2email.py and modify them to do
>>> what you need to do.
>>>
>>>
>>> On Wednesday, 8 January 2014 23:27:46 UTC-6, James Q wrote:
>>>>
>>>> Interesting. I have never written wsgi middleware, any pointers on
>>>> that? As middleware, I would still need to have an understanding of how to
>>>> detect if an exception has been logged in the request, no?
>>>>
>>>> Thanks!
>>>>
>>>> -- J
>>>>
>>>> On Tuesday, January 7, 2014 8:24:14 PM UTC-5, Derek wrote:
>>>>>
>>>>> I haven't, but I've done something similar with a different piece of
>>>>> software. You'd usually just use it as a wsgi middleware around your app.
>>>>> So you'd need to run web2py as wsgi and wrap it with Sentry.
>>>>>
>>>>> On Monday, January 6, 2014 8:14:46 PM UTC-7, James Q wrote:
>>>>>>
>>>>>> Has anyone ever integrated web2py an Sentry (
>>>>>> https://github.com/getsentry/sentry)? I would like it if all web2py
>>>>>> generated exceptions generate a ticket like usual, but also generates an
>>>>>> event to a sentry server. Has anyone ever done this? If not, could anyone
>>>>>> point to where I would need to patch web2py or how best this integration
>>>>>> would work?
>>>>>>
>>>>>> Thanks for any help!
>>>>>>
>>>>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/cYXGl7rlvKQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Web2py Integration with Sentry

2014-01-14 Thread James Q
Massimo: Would you consider taking a patch / pull request for a new script?

-- James

On Thursday, January 9, 2014 9:16:02 AM UTC-5, Massimo Di Pierro wrote:
>
> The problem is that it would not work. you can have exceptions at two 
> levels: web2py apps, web2py itself. In other frameworks these two levels 
> are mixed up so sentry will catch either exceptions. In web2py the two 
> levels are well separated and web2py catches app exceptions before they 
> propagate up and sentry would not catch them. sentry would only catch 
> exceptions in web2py itself and that is pretty much useless. 
>
> You can think about it in another way, web2py already has a mechanism to 
> catch exceptions and log them. and you cannot do:
>
> try:
> try:
>   do something
>exceptiion: 
>   web2py ticket system
> except:
>sentry logging system
>
> and expect the second except to catch anything. Look instead into 
> scritps/tickets2db.py and scripts/tickets2email.py and modify them to do 
> what you need to do.
>
>
> On Wednesday, 8 January 2014 23:27:46 UTC-6, James Q wrote:
>>
>> Interesting. I have never written wsgi middleware, any pointers on that? 
>> As middleware, I would still need to have an understanding of how to detect 
>> if an exception has been logged in the request, no?
>>
>> Thanks!
>>
>> -- J
>>
>> On Tuesday, January 7, 2014 8:24:14 PM UTC-5, Derek wrote:
>>>
>>> I haven't, but I've done something similar with a different piece of 
>>> software. You'd usually just use it as a wsgi middleware around your app. 
>>> So you'd need to run web2py as wsgi and wrap it with Sentry.
>>>
>>> On Monday, January 6, 2014 8:14:46 PM UTC-7, James Q wrote:
>>>>
>>>> Has anyone ever integrated web2py an Sentry (
>>>> https://github.com/getsentry/sentry)? I would like it if all web2py 
>>>> generated exceptions generate a ticket like usual, but also generates an 
>>>> event to a sentry server. Has anyone ever done this? If not, could anyone 
>>>> point to where I would need to patch web2py or how best this integration 
>>>> would work?
>>>>
>>>> Thanks for any help!
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Web2py Integration with Sentry

2014-01-09 Thread James Q
Interesting. I have never written wsgi middleware, any pointers on that? As 
middleware, I would still need to have an understanding of how to detect if 
an exception has been logged in the request, no?

Thanks!

-- J

On Tuesday, January 7, 2014 8:24:14 PM UTC-5, Derek wrote:
>
> I haven't, but I've done something similar with a different piece of 
> software. You'd usually just use it as a wsgi middleware around your app. 
> So you'd need to run web2py as wsgi and wrap it with Sentry.
>
> On Monday, January 6, 2014 8:14:46 PM UTC-7, James Q wrote:
>>
>> Has anyone ever integrated web2py an Sentry (
>> https://github.com/getsentry/sentry)? I would like it if all web2py 
>> generated exceptions generate a ticket like usual, but also generates an 
>> event to a sentry server. Has anyone ever done this? If not, could anyone 
>> point to where I would need to patch web2py or how best this integration 
>> would work?
>>
>> Thanks for any help!
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Web2py Integration with Sentry

2014-01-07 Thread James Q
Has anyone ever integrated web2py an Sentry 
(https://github.com/getsentry/sentry)? I would like it if all web2py 
generated exceptions generate a ticket like usual, but also generates an 
event to a sentry server. Has anyone ever done this? If not, could anyone 
point to where I would need to patch web2py or how best this integration 
would work?

Thanks for any help!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.