Today I decided to upgrade my local bugzilla from bz3.6 to bz 4.2, and got lots of errors and headaches for sure. The following are the bugs:
1, xmlrpc support are disabled, this is caused by failed to load required modules, to fix this is very easy, i just ran install all modules, may you are interesting with how i found this, we are using bugzilla xmlrpc for updating our data, after failed several times, and double checked our code, we thought it's bugzilla installation issues.
2, DB schema didn't match, first i delete record in bz_schema table, then ran checksetup.pl, then some errors were emerging, basically they were foreign key constrain issues, so I deleted those foreign keys from related tables, believe me, that's a huge task
3, there were some invalid data in db already, so if that's true, correct those are delete them
Thursday, July 12, 2012
Monday, July 9, 2012
opera interview
General:
1, Regular expression
2, how to retrieve the main body of a html page
3, write a B(tree, *, +)
4, how to implement a long HTTP connection if proxy doesn't support connection header
PY related:
1, import details
2, yield details
3, meta programming
Mysql related:
1, mysql index
1, Regular expression
2, how to retrieve the main body of a html page
3, write a B(tree, *, +)
4, how to implement a long HTTP connection if proxy doesn't support connection header
PY related:
1, import details
2, yield details
3, meta programming
Mysql related:
1, mysql index
Tuesday, June 26, 2012
some key characters about REST
Two important question for classifying web services:
1, The scoping information is kept in the URI. This is the principle of addressability
2, The method information is kept in the HTTP method, CRUD
Restful web service should be stateless, that's every request should contain the required information to make this request. The violation for this is using cookie to maintain the state. E.g. goolge search, i can bookmark the results page 10 of keywords jellyfish as q?search=jellyfish&page=10, server side doesn't need to maintain the page index information for the request, the request contains all the information needed for server to response it.
I'm reading the Restful Web Services' chapter4, and this stateless description makes me double thinking about our Mobile APP's Backend, I'm now using session cookie to authenticate users when he issues a request after logged in, such as updating profile. We are still heavily relying on the cookie based authentication procedure, this is not good to name it as Restful.
One difference between HTTP PUT and POST is that, with PUT the client should know what URI for the new created resource should be, and POST are more likely as operation append. Sometime, we may overload HTTP POST method as a process request to a resource, this method sometimes reduce the complexity(It's RPC style web service, that's method information creep into other place instead of uniform HTTP Method).
More words for overload POST, actually, if we stick with PUT to get (Read) information, and POST for modifying, deleting or creating a resource, it's still Restful.
ROA:
for concepts:
1, Resource
2, Their name(URI)
3, Their representation
4, THe links between them
for properties:
1, Addressability
2, statelessness
3, Connectedness
4, A uniform interface
1, The scoping information is kept in the URI. This is the principle of addressability
2, The method information is kept in the HTTP method, CRUD
Restful web service should be stateless, that's every request should contain the required information to make this request. The violation for this is using cookie to maintain the state. E.g. goolge search, i can bookmark the results page 10 of keywords jellyfish as q?search=jellyfish&page=10, server side doesn't need to maintain the page index information for the request, the request contains all the information needed for server to response it.
I'm reading the Restful Web Services' chapter4, and this stateless description makes me double thinking about our Mobile APP's Backend, I'm now using session cookie to authenticate users when he issues a request after logged in, such as updating profile. We are still heavily relying on the cookie based authentication procedure, this is not good to name it as Restful.
One difference between HTTP PUT and POST is that, with PUT the client should know what URI for the new created resource should be, and POST are more likely as operation append. Sometime, we may overload HTTP POST method as a process request to a resource, this method sometimes reduce the complexity(It's RPC style web service, that's method information creep into other place instead of uniform HTTP Method).
More words for overload POST, actually, if we stick with PUT to get (Read) information, and POST for modifying, deleting or creating a resource, it's still Restful.
ROA:
for concepts:
1, Resource
2, Their name(URI)
3, Their representation
4, THe links between them
for properties:
1, Addressability
2, statelessness
3, Connectedness
4, A uniform interface
setup a local envrionment for openshift wsgi app
We do want a local development environment for debugging, etc. As my previous posts, we are using Python2.6 Django WSGI as backend for our mobile app, so, it's pretty easy to setup a local environment, actually, it's just a WSGI deployment.
But, since openshift gear using many environment variables, so the key steps here are copy those env vars to your local box, and export them. The another thing that matters a lot is Database setup, with help of Django Framework, i just need to create a database with the same name as it is in openshift, and then run syncdb.
The issue bit me was Selinux settings, so you may need pay some attentions to it. If you have an admin beside you, drop these setup stuff to him, :).
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/
But, since openshift gear using many environment variables, so the key steps here are copy those env vars to your local box, and export them. The another thing that matters a lot is Database setup, with help of Django Framework, i just need to create a database with the same name as it is in openshift, and then run syncdb.
The issue bit me was Selinux settings, so you may need pay some attentions to it. If you have an admin beside you, drop these setup stuff to him, :).
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/
Tuesday, June 19, 2012
redirect http to https for your openshift application
Want to use HTTPS for you openshift application? Yes, our application as mobile app's backend definitely needs this feature, I though there should be some other additional complex, obscure steps to enable HTTPS. But actually, it's very easy, just add .htaccess file in your wsgi directory(I'm using python, django application, you should do this according to your specific requirement).
here is the content for redirecting HTTP to HTTPS:
Now, all your requests will be porting to HTTPS, if you have some cookies in your browser, you should clear those insecure cookies, otherwise you may can not login.
here is the content for redirecting HTTP to HTTPS:
RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://%{HTTP_HOST}%{REQUEST} [R,L]
Now, all your requests will be porting to HTTPS, if you have some cookies in your browser, you should clear those insecure cookies, otherwise you may can not login.
Monday, June 18, 2012
howto create a django application in openshift(wsgi related)
we are using openshift as our mobile app's backend since we don't have much resource and money to buy a server for hosting this backend site. It's a great Pass platform for developers saving much headaches. Every account has one domain associated, we can create 3 apps under it, e.g. you create a domain map, and then create a app social, the application's full URL will be social-map.rhcloud.com. You can check its features in http://openshift.redhat.com .
Django is our backend web framework, and there's a quick start example in github(github.com/openshift/django-example), you can just clone this repo, and push it to your repo, then openshift will deploy it for you.
But we decided to do it ourselves(why we need those unrelated dirs, codes, it's really annoying), it's very easy. Here are some steps:
1, clone your app repo into local working directory, when you create an app, openshift will create a git repo for you, and you can add other remote repos, and push/pull from there, it's up to you.
2, edit setup.py, add 'Django>=1.3' into install_requires
3, use django-admin.py creating a new project under your working directory, there will be one wsgi file generated, after step 4, you can delete this
4, edit wsgi/application file, you can setup environment vars there, the important thing is help it finding your site's setting.py
5, ok, you have done the setup stuff, now you can continue your coding, and then push it to openshift
ps, our directory structure:
.
|-- data
|-- libs
|-- socialmap (this is our django project)
| |-- accounts
| | `-- avatars
| `-- templates
`-- wsgi (wsgi file application mentioned in step4 is in this directory)
`-- static
`-- admin
|-- css
|-- img
| `-- gis
`-- js
`-- admin
Django is our backend web framework, and there's a quick start example in github(github.com/openshift/django-example), you can just clone this repo, and push it to your repo, then openshift will deploy it for you.
But we decided to do it ourselves(why we need those unrelated dirs, codes, it's really annoying), it's very easy. Here are some steps:
1, clone your app repo into local working directory, when you create an app, openshift will create a git repo for you, and you can add other remote repos, and push/pull from there, it's up to you.
2, edit setup.py, add 'Django>=1.3' into install_requires
3, use django-admin.py creating a new project under your working directory, there will be one wsgi file generated, after step 4, you can delete this
4, edit wsgi/application file, you can setup environment vars there, the important thing is help it finding your site's setting.py
5, ok, you have done the setup stuff, now you can continue your coding, and then push it to openshift
ps, our directory structure:
.
|-- data
|-- libs
|-- socialmap (this is our django project)
| |-- accounts
| | `-- avatars
| `-- templates
`-- wsgi (wsgi file application mentioned in step4 is in this directory)
`-- static
`-- admin
|-- css
|-- img
| `-- gis
`-- js
`-- admin
Tuesday, June 12, 2012
use Devel::NYTProf to profile perl cgi
Recently, we are bitten by the venomous performance issues, our web site users are keeping complaining about the speed, so i tried to find some tools to profile our web site. And finally got a awesome perl module, yep, that is Devel::NYTProf, it can generate well formatted report such as html, csv, etc.
Since our website is perl-cgi powered(LAMP), so it cost me some time to configure profile environment, tried lots of methods provided by enthusiastic people, e.g. SetEnv in Apache config file. But those all failed, it really frustrated.
At the end, i found a post, it says, we can just append -d:NYTProf to the specific cgi after the shebang
'#!/usr/bin/perl -wT -d:NYTProf', then, we can request that cgi, there will be one file namely nytp.out in your cgi directory, with this file we can generate good-looking report.
ps:
http://blip.tv/timbunce/devel-nytprof-v4-oscon-201007-3932242
http://search.cpan.org/dist/Devel-NYTProf/
Since our website is perl-cgi powered(LAMP), so it cost me some time to configure profile environment, tried lots of methods provided by enthusiastic people, e.g. SetEnv in Apache config file. But those all failed, it really frustrated.
At the end, i found a post, it says, we can just append -d:NYTProf to the specific cgi after the shebang
'#!/usr/bin/perl -wT -d:NYTProf', then, we can request that cgi, there will be one file namely nytp.out in your cgi directory, with this file we can generate good-looking report.
ps:
http://blip.tv/timbunce/devel-nytprof-v4-oscon-201007-3932242
http://search.cpan.org/dist/Devel-NYTProf/
Subscribe to:
Posts (Atom)