Posts Tagged With ‘Python&8217


Tell Me Again, What was The Semantic Web?

My semantic web interest is almost two years old however, I haven’t focused it enough till this year. It was something like a magazine or a blog that I like to read or follow but never involved. Somehow, my viewpoint on semantic web extremely changed and I’ve started scientific (also business) researches on semantic web.

Today, I felt much better when I saw the following videos. It was a right choice to make investments on semantic web. I hope, it will much better… Thanks Cas for sharing these nice videos:


Future Internet Video from Castemelijn on Vimeo

Impressed Kevin Kelly’s presentation and the quote about web: “Have to get better in believing the impossible”

Tomorrow, I have a meeting with my advisers about Semantic Web for P2P networks and if it goes successfully, I’ll start build my project in the following weeks. First, I want to up and running simplest p2p network in my local machine using twisted on python or jxta on java. Then give this thing a mining: semantic …


A Real Django Application On A Shared Hosting

I got working a simple django application on a shared hosting before but never tried a real application till to night. I was developing a project for fun nothing much and it is about to finish and ready for a real time test. After struggling with .haccess mod_rewrite issues1 (mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use ‘RewriteOptions MaxRedirects’ to increase the limit if neccessary) my application is deployed and first http request is called. No, as you guess it didn’t work. My hosting provider uses an old version of mysql driver for python which is MySQLdb-1.2.0 but django 1.0 requires MySQLdb-1.2.1p2 or newer. So, planning to email and ask them if it is possible to upgrade driver if not I’m going to use my friends home servers to host it.

1 To fix this issue add your domain name to rewrite condition like
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} yoursite.com
RewriteCond %{REQUEST_URI} !yoursite.com
RewriteRule ^(.*)$ cgi/yoursite.cgi/$1 [QSA,L]


I’m Free For a While

I woke up at 4:30 am last night and it is about to 2:00 am. Yes, It makes a lot of time. I was dealing with graduate studies for last two weeks and I’ve completed most important part this night. I made a paper submission to local conference in Turkey which will be held at Harran Uni. Only a few final exams left which are not a big issue to handle.So, I’m free for a while and my plan is to complete the following todo list:

Trying to figure out Is it possible to say “free for a while” while having this list.

Why didn’t I quit and sleep instead of blogging?


Django on Shared Hostings

I spent last night setting up django a cgi enabled shared hosting. I faced some problems during this process and I decided to write a how to about “django on shared hosting”.

First of all, make sure your editor supports Unix file format. It took my whole night to determine why I was getting internal server error. I tried some free editor on windows and it seems Komodo Edit is the best one.

Second, make sure your hosting supports python, to test it you can use this script below. Don’t forget to change file permissions (755 is fine) to run it.
#!/usr/bin/python
print "Content-type: text/html"
print
print "<pre>"
import os, sys
from cgi import escape
print "<strong>Python %s</strong>" % sys.version
keys = os.environ.keys()
keys.sort()
for k in keys:
print "%st%s" % (escape(k), escape(os.environ[k]))
print "</pre>"

Now, prepare two folders to store your python lib and django projects, in your hosting something like /home/username/python and /home/username/projects, then get django and flup unzip and upload these libraries to python folder and upload your site to projects folder. Don’t forget to change permissions of your project to 755.

Almost done, a script is need to handle request;
import sys, os
sys.path += ["/home/username/python"]
sys.path += ["/home/username/projects "]
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

You may need to place this script under the cgi-bin(or cgi) director. Some hosting providers don’t support fastcgi to run everywhere.

Now, modify and place following lines to your .htaccess file. mysite.cgi is the script above.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi/mysite.cgi/$1 [QSA,L]

Done, call your domain, you will have django welcome message.


Building Python Modules on Windows

Python is a great cross platform application development environment. There is a  wide range of python modules (libraries) available. In most cases, module distributors supply platform specific installers which already built or at least they distribute the source code and let it to be built and installed by developers.

It is easy to build and install any python module in a Unix system. Because all *nix systems have a built in  development environment to build python modules ( or any language). So, just typing “python setup.py buil” and “python setup.py install” will be enough to get things done. Hard part is
having a windows. There are some options this issue:

1 -) Using MS Visual Studio ( I hate it)
2 -) Using Cygwin to get gcc for Windows
3 -) Using MinGW to get gcc for Windows

I choosed the 3rd option, it is the easiest one. What you have to do is get MinGW installer
and install required compilers and set it to your OS path. Mine is “C:MinGWbin”. Then, open a command prompt and cd to the source folder of the python module. Run build statement “python setup.py build -c mingw32” this will build your module and get it ready to use. The build tool will generate a folder called “buildlib.win32-*.*” which contains compiled libraries. Copy those libraries to somewhere in python classpath. Mine is located at “C:Python25Lib”. That is it.You are ready to use your module. To test it, you can use pycrypto.