Is there anyone who running web2py application on Redhat openshift?

463 views
Skip to first unread message

JungHyun Kim

unread,
May 15, 2012, 3:55:07 AM5/15/12
to web...@googlegroups.com
Hello. I'm now trying to use redhat openshift.

I am struggling access database - mysql-5.1 - which is set via openshift cartridge.
I got admin user(admin), password and database name(we2py).
So I modified database setting in models/db.py 

as


But web2py application can't connect to mysql.

OperationalError: (2003, "Can't connect to MySQL server on 'web2py-codingday.rhcloud.com' (111)")

I think I couldn't understand enough. I am a noob for both web2py and openshift.

How can I make web2py connect to database right?

Thank you.


Ross Peoples

unread,
May 15, 2012, 7:51:26 AM5/15/12
to web...@googlegroups.com
I don't know anything about openshift, but I would think the normal MySQL troubleshooting steps apply:

  1. Make sure MySQL is listening on all interfaces
  2. Make sure your MySQL account accepts connections from the '%' host.

On Tuesday, May 15, 2012 3:55:07 AM UTC-4, JungHyun Kim wrote:
Hello. I'm now trying to use redhat openshift.

I am struggling access database - mysql-5.1 - which is set via openshift cartridge.
I got admin user(admin), password and database name(we2py).
So I modified database setting in models/db.py 

as


But web2py application can't connect to mysql.

JungHyun Kim

unread,
May 15, 2012, 8:31:28 AM5/15/12
to web...@googlegroups.com
Thank you! Ross!

The problem was mysql URL. It was different from application URL(=web2py-codingday.rhcloud.com).

Now connection to mysql is OK. But still there is HTTP 500 error with default welcome application... 
I should spend more to know why.




2012년 5월 15일 화요일 오후 8시 51분 26초 UTC+9, Ross Peoples 님의 말:

Andrew

unread,
May 15, 2012, 2:15:28 PM5/15/12
to web...@googlegroups.com
JungHyun,

I've deployed the default web2py app to Openshift with no issues but haven't played with it much. I'd be happy to share my project dir so you can see how I've structured my wsgi file and various libs like gluon so that the app will run. 

I'll try and create a mysql cartridge and put the model in that to see what happens.

Andrew


On Tuesday, May 15, 2012 2:55:07 AM UTC-5, JungHyun Kim wrote:
Hello. I'm now trying to use redhat openshift.

I am struggling access database - mysql-5.1 - which is set via openshift cartridge.
I got admin user(admin), password and database name(we2py).
So I modified database setting in models/db.py 

as


But web2py application can't connect to mysql.

JungHyun Kim

unread,
May 16, 2012, 12:41:13 PM5/16/12
to web...@googlegroups.com
Thank you Andrew!

I connected mysql successfully (I guess, cause the error message disappeared).


If I can see your project settings, it will be really helpful!




2012년 5월 16일 수요일 오전 3시 15분 28초 UTC+9, Andrew 님의 말:

JungHyun Kim

unread,
May 18, 2012, 3:34:16 AM5/18/12
to web...@googlegroups.com
Andrew.

If you don't mind, would you see my WSGI application setting?

I modified "application" file in project/wsgi directory.

from web2py import wsgihandler
application = wsgihandler.application

Variable "application" seems a main handler of web request.
(Initially it was a function which renders HTML code)


Now I am struggling with this error

<type 'exceptions.AttributeError'> 'thread._local' object has no attribute 'request'



in application/welcome/models/db.py
39.
40.
41.
42.
43.
44.

45.
46.
47.
48.
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())

crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables()


in  gluon/tools.py 
   @staticmethod
def get_or_create_key(filename=None):
request = current.request

if not filename:
filename = os.path.join(request.folder,'private','auth.key')
if os.path.exists(filename):
key = open(filename,'r').read().strip()



Variables
global current<thread._local object>
requestundefined
current.requestundefined


Thank you very much.

JungHyun



2012년 5월 16일 수요일 오전 3시 15분 28초 UTC+9, Andrew 님의 말:
JungHyun,

Andrew

unread,
May 18, 2012, 11:14:05 PM5/18/12
to web...@googlegroups.com
JungHyun,


Here's my project structure with application file attached- Let me know if this helps.

data/
    .
    ..
    
libs/
    gluon (moved from web2py dir)

wsgi/
    application - Attaching this to post
    web2py/
          ..std web2py minus gluon dir moved to libs..

.openshift/ (nothing modified)
     action_hooks
     cron
     markers

On Tuesday, May 15, 2012 2:55:07 AM UTC-5, JungHyun Kim wrote:
Hello. I'm now trying to use redhat openshift.

I am struggling access database - mysql-5.1 - which is set via openshift cartridge.
I got admin user(admin), password and database name(we2py).
So I modified database setting in models/db.py 

as


But web2py application can't connect to mysql.
application.zip

JungHyun Kim

unread,
May 19, 2012, 6:44:31 AM5/19/12
to web...@googlegroups.com
Andrew!!

It works !!!

Two things were keys.

1. setting gluon module in "libs" directory
2. and making environment to see that module.

Thank you for your help! :)


2012년 5월 19일 토요일 오후 12시 14분 5초 UTC+9, Andrew 님의 말:

Andrew

unread,
May 19, 2012, 12:14:56 PM5/19/12
to web...@googlegroups.com
Glad to hear it! =]

I'll post my application file to the openshift forums and see if that helps them get a skeleton up on github for web2py. 

Andrew

Changju

unread,
May 20, 2012, 12:21:47 PM5/20/12
to web...@googlegroups.com
Hi JungHyun.
I have one question for you.
I don't know about Openshift but I want to know why you chose Openshift other than Pythonanywhere or Fluxflex which are all free for low traffic.

Thanks,
Changju

JungHyun Kim

unread,
May 21, 2012, 3:05:43 AM5/21/12
to web...@googlegroups.com

Hello Changju.

Frankly speaking, I didn't know either pythonanywhere or fluxflex.
So after read your mail, I compared their free tiers roughly. 

  1. OpenShift  :  512MB of RAM,  and 1GB of disk space(probably including DB storage)  * 3 applications 
  2. Pythonanywhere  :  CPU(quota or performance) and Bandwidth are not specified in detail,  500MB of storage  *  5 applications 
  3. Fluxflex  :  0.25hours of CPU time, 250MB disk space and 25MB of DB storage  * 2 applications

Among  3 free plans, Openshift looks better than others. 
The only thing I am apprehensive is that I couldn't find the information about CPU quota or network bandwidth limit in Openshift document.
Now I just guess there are no limitations in CPU and network. If they are not, please let me know :)
If you recommend Pythonanywhere and Fluxflex, would you explain their advantages for this group members?


ps. Are you rookiecj? I read some posts from your blog. I'm glad to see you! :)


2012년 5월 21일 월요일 오전 1시 21분 47초 UTC+9, Changju 님의 말:
2012년 5월 21일 월요일 오전 1시 21분 47초 UTC+9, Changju 님의 말:

Changju

unread,
May 22, 2012, 8:33:56 AM5/22/12
to web...@googlegroups.com
Hi JungHyun. 
Yes, I'm rookiecj. Nice to meet you :)

Pythonanywhere, as you can see from the name, they provide a good tools for people who like python and web2py. 
They provide 
- a shell through Web(through port 80) that you can login from anywhere.
- quick setup for web2py already.
- relatively cheep price then other's(yeah it's little bit ambiguous on their Bandwidth).

Fluxflex, I like the AppGarage where you can choose web applications you want to install then just click them, now you have your one service. that's all.
You can serve your own web service like Blog in a minute.

Anyway, can I send an email in person?

JungHyun Kim

unread,
May 25, 2012, 11:08:47 AM5/25/12
to web...@googlegroups.com

Hi Changju.

I tried pythonanywhere. It was awesome. Very very easy to use. 
I may use pythonanywhere for my next project.

Anyway, of course you can send me an email in person.
I will be very glad if I receive from you.

Thank you.




2012년 5월 22일 화요일 오후 9시 33분 56초 UTC+9, Changju 님의 말:
Reply all
Reply to author
Forward
0 new messages