Ronnie Beltran | 7 Feb 03:22
Picon

CherryPy Facebook Authentication on Google Appengine

Hi I asked this question
http://stackoverflow.com/questions/9045244/cherrypy-facebook-authentication-on-google-appengine
at SO but no answer yet. Can somebody here help?

--

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

Michiel Overtoom | 7 Feb 09:01
Picon
Picon
Favicon
Gravatar

Re: cgitb wierdness with CP


On Jan 29, 2012, at 03:00, Scott Chapman wrote:

> I'm not at all clear why this is doing this.  Of course this makes
> debugging database issues more fun.

I see you're using MySQL as a database, and undoubtly the underlying libmysql at some point. Libmysql is not
threadsafe, and CherryPy is threaded. In my case that gave problems (segfaults!) and I had to use
something like DBUtils to get around that. I'm not sure this is applicable to your situation.

Greetings,

-- 
Test your knowledge of flowers! http://www.learn-the-flowers.com
or http://www.leer-de-bloemen.nl for the Dutch version.

Test je kennis van bloemen! http://www.leer-de-bloemen.nl
of http://www.learn-the-flowers.com voor de Engelse versie.

--

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

Gravatar

Re: CherryPy Facebook Oauth 2.0 on Google Appengine

Hi Ronnie,



On Sun, Jan 29, 2012 at 5:09 AM, Ronnie Beltran <rbbeltran.09-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
I'm trying to port a sample facebook oauth 2.0 auth from webapp to
cherrypy. however it always return a None value in self.current_user.
I think I'm having trouble with settings cookies here. any
corrections? see http://errorpaste.appspot.com/logs/4001/cherrypy-facebook-authentication-on-google-appengine
for more deatils.



It may not be the cause of your error, you shouldn't set attributes to the Root class when using it as a CherryPy application since CP is threaded. Rather attach it to the current request object.
Though it might not answer your specific use case, you might want to look at this code for an example of OAuth with CherryPy:

The tool that attaches the current user to the current request:

The plugin that provides OAuth support for the application:

The app itself:

How you setup everything together:

--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cherrypy-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.
Sebastian Rahlf | 11 Feb 10:46
Picon

How to tell Cherrypy to use any available port?

Hello!

This has been asked before but I could not find a satifying answer.

I want to use CherryPy in a test suite. It will always run on
localhost but I have no chance of knowing which ports will be
available beforehand as there may already be another instance started
by another test.

The way I went about this previously was to bind to ('127.0.0.1', 0)
which would guarantee an open port to be used. How would I do this
with CherryPy? Using module random, as previously suggested, is not an
option for me.

Thanks for any pointers!

Seb.

--

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

Daniel Bryan | 11 Feb 13:10
Picon
Gravatar

Re: How to tell Cherrypy to use any available port?

Being a total cherrypy amateur I'm sure the community will have a much better suggestion than me, but perhaps during your server startup you could create simple socket connections, wrapped in a try/except, and iterate through a range of acceptable port numbers until you get one that's available (and which you have permission for)? Something like this..


import socket

def find_port(acceptable_ports):
port = acceptable_ports.pop()
while port in acceptable_ports:
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
serversocket.bind((socket.gethostname(), port))
return port
except socket.error:
port = acceptable_ports.pop()
raise IOError('No available ports in your range sucked in')
port = find_port(range(1,80))

Goes without saying that this is ad hoc, ugly, probably breaks a whole bunch of import principles of network programming and good process behaviour. I'm sure there's some way to do this in a single line. 

On Sat, Feb 11, 2012 at 8:46 PM, Sebastian Rahlf <basti <at> rotekroete.de> wrote:
Hello!

This has been asked before but I could not find a satifying answer.

I want to use CherryPy in a test suite. It will always run on
localhost but I have no chance of knowing which ports will be
available beforehand as there may already be another instance started
by another test.

The way I went about this previously was to bind to ('127.0.0.1', 0)
which would guarantee an open port to be used. How would I do this
with CherryPy? Using module random, as previously suggested, is not an
option for me.

Thanks for any pointers!

Seb.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to cherrypy-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cherrypy-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.
Daniel Bryan | 11 Feb 13:13
Picon
Gravatar

Re: How to tell Cherrypy to use any available port?

Oh, my while loop there is fundamentally broken. Joy! This is what you get for answering list questions after months of no Python -___-

On Sat, Feb 11, 2012 at 11:10 PM, Daniel Bryan <danbryan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Being a total cherrypy amateur I'm sure the community will have a much better suggestion than me, but perhaps during your server startup you could create simple socket connections, wrapped in a try/except, and iterate through a range of acceptable port numbers until you get one that's available (and which you have permission for)? Something like this..

import socket

def find_port(acceptable_ports):
port = acceptable_ports.pop()
while port in acceptable_ports:
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
serversocket.bind((socket.gethostname(), port))
return port
except socket.error:
port = acceptable_ports.pop()
raise IOError('No available ports in your range sucked in')
port = find_port(range(1,80))

Goes without saying that this is ad hoc, ugly, probably breaks a whole bunch of import principles of network programming and good process behaviour. I'm sure there's some way to do this in a single line. 

On Sat, Feb 11, 2012 at 8:46 PM, Sebastian Rahlf <basti-kTgxEZxlji3UTce7r8oAew@public.gmane.org> wrote:
Hello!

This has been asked before but I could not find a satifying answer.

I want to use CherryPy in a test suite. It will always run on
localhost but I have no chance of knowing which ports will be
available beforehand as there may already be another instance started
by another test.

The way I went about this previously was to bind to ('127.0.0.1', 0)
which would guarantee an open port to be used. How would I do this
with CherryPy? Using module random, as previously suggested, is not an
option for me.

Thanks for any pointers!

Seb.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.



--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cherrypy-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.
Dave B. | 20 Feb 16:59

easiest way to organize/create installations/eggs for multiple applications under one CherryPy server?

Hi,

I currently have one application running under CherryPy.  My next
project will involve creating another application that I would like to
also run under the same CherryPy server.  I have two basic questions,
both having to do with simplicity/"best practices":

1) How to best organize files/directories?  Right now the directory
structure is basically:

[server]
  +---- setup.py
  +----[server]
          +---- server.py (CherryPy server and apps setup/launch
module)
          +----[etc] -> server.conf (<cherrypy.config>; contains an
"apps" setting dictionary with info to create each app)
          +----[logs] -> server.log (<cherrypy.log.error_log>)
          +----[apps]
                  +----[app1]
                          +----setup.py
                          +----[app1]
                                  +---- app1.py + other app1 modules
                                  +----[etc] -> app1.conf
(<app1.config>)
                                  +----[logs] -> app1.log
(<app1.log.error_log>)
                  +----[app2] (future)
                          +----setup.py
                          +----[app2]
                                  +---- app2.py + other app2 modules
                                  +----[etc] -> app2.conf
(<app2.config>)
                                  +----[logs] -> app2.log
(<app2.log.error_log>)

I currently have app1 working under the server, and I would like to be
able to simply "plug-in" app2 when it is completed.

2) If the above is OK, how can the setup.py files be laid out to
create eggs to install the above?  I have been thinking a server egg
could be installed first into site-packages, and then individual
application eggs could be installed "underneath" the server somehow.
But I'm not sure that's possible.  Or is it better to reorganize,
making each application directory structure a "peer" to the server
directory structure?  That would seem to allow eggs to install the
server and applications as "peers" under site-packages.

Thanks very much for any advice.  I'm just looking for the best
combination of simplicity and flexibility/expandibility.  I thought
I'd be able to quickly find guidance somewhere, but so far am striking
out.

Dave B.

--

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

Dave B. | 21 Feb 00:00

Re: easiest way to organize/create installations/eggs for multiple applications under one CherryPy server?

I should add a third choice for installation is to create one large
egg containing the server and all the apps.  That is probably the way
I will go unless someone can illuminate me (including stumbling on
something illuminating myself)...

Thanks again for any guidance,

Dave B.

--

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

Lukasz Michalski | 22 Feb 08:31
Picon

How to alter exception handling in the right way

Hi,

I am trying to alter default error page generation for single page
handler class. When MyException is thrown by any of my page handler I
would like to return custom error page. But for any other kind of
exceptions I would like to use default exception handling process.

My current solution is below:

def my_error_handler():
    exctype,excobj = exc_info()[:2]
    if exctype is not MyException:
        cherrypy.HTTPError(500).set_response()
    else:
        cherrypy.response.status = 404
        cherrypy.response.body = generate_error_page(excobj)

class Root(object):
    _cp_config = {
      'request.error_response': my_error_handler
    }

    @cherrypy.expose
    def page1:
	[...]

    @cherrypy.expose
    def page2:
        [...]

What I do not like about it is cherrypy.HTTPError(500).set_response().
Is there a better way to fallback to default error response generation?

Thanks!,
Ɓukasz

--

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

Nav | 22 Feb 11:14
Picon

Cherrypy serving the same object data to different users

Hi Guys,

I am in a fix. I am working with Cherrypy3.2 and python 3.2, I created
a form library and below is a summary of my code:

@cherrypy.expose
def index(self, **kwargs):
      method = cherrypy.request.method

     if method == 'POST':
           form = NewForm(validate_data=kwargs)
           #validate form
           cherrypy.HTTPRedirect('address_of_same_form')
     else:
           form = NewForm()

    return response...

The above code is supposed to validate a form on POST and if errors
are formed resend the form back to the user with errors. Now, no
matter what I do, if one user gets an error, the other user on opening
the same form can see the error on his/her page, when that user has
not even entered anything.

What am I doing wrong?

Please help...

Regards,
Nav

--

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


Gmane