Версии:
- Cherokee: 1.0.8
- uwsgi: uWSGI 0.9.6-dev (скомпилировано под Python 2.6)
Все скомпилировано из свежих репозиториев. Ранее у меня не получалось настроить чероки - визард не находил uwsgi. Сейчас в новой версии - все супер!
Личный блог Фунтикова Виталия. Full stack developer
wget http://python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2 tar -xjf Python-2.6.4.tar.bz2 cd Python-2.6.4 yum install -y gcc make zlib-devel bzip2-devel openssl-devel readline-devel sqlite-devel gdbm-devel ncurses-devel ./configure --prefix=/opt/python26 --with-zlib=/usr/include make make install ln -s /opt/python26/bin/python2.6 /usr/bin/python2.6 python2.6 -V
wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086 sh setuptools-0.6c11-py2.6.egg ln -s /opt/python26/bin/easy_install-2.6 /usr/bin/easy_install-2.6 easy_install-2.6 --help
pyodbc.ProgrammingError: ('42000', '[42000] [FreeTDS][SQL Server]Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (4004) (SQLExecDirectW)')
[FreeTDS] Description=TDS driver Driver=/usr/lib/libtdsodbc.so Setup=/usr/lib/libtdsS.so FileUsage=1
[myServer]
host=192.168.0.2
port=1433
tds version=8.0
Особенно прошу учесть "табы" перед параметрами! У меня без них запись не срабатывала![myDNS] Description=my dsn Driver=FreeTDS Database=my_db Servername=myServer
import pyodbc
conn = pyodbc.connect("dsn=myDSN;UID=%s;PWD=%s;" % ('sa','pass'))
cursor=conn.cursor()
cursor.execute("select 'test' as x;")
row=cursor.fetchone()
if row:
print row
set nocount on;Тогда данные получаются нормально.
class Controller():
def __init__(self, request):
def get(self): #вызывается при get-запросе
def post(self): #вызывается при post-запросе
def render_template(self, template, **context): #так вызывается шаблонизатор
def preprocess(self): # дергается в конце инициализации. сюда можно навесить декоратор для проверки прав доступа
Кроме того, Controller при каждой инициализации создает в себе объект self.current_user - думаю понятно что это :-)def index(request):
return HttpResponse('hello from django!')
3. установил cherokee последнюю версию из svn (на сайте чероки описано как это сделать), т.к. в текущей 0.99.19 нет визарда для настройки uWSGI...<uwsgi>
<pythonpath>/var/www-cherokee/</pythonpath>
<pythonpath>/var/www-cherokee/django1</pythonpath>
<app mountpoint="/">
<script>/django1/django_wsgi</script>
</app>
</uwsgi>
обратите внимание на пути в pythonpath - без них работать не будет.#some code for run on cherokee web server import os import django.core.handlers.wsgi os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' application = django.core.handlers.wsgi.WSGIHandler()8. в настройках cherokee (в которые легко попасть через sudo cherokee-admin -u и потом в браузере http://localhost:9090) нужно в разделе "Virtual Server: default" вызвать "wizards"->platforms ->uWSGI ->run wizard.
application: fun-test version: 2 runtime: python api_version: 1 handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py login: admin - url: /.* script: main.py
# coding=UTF-8
import datetime
from google.appengine.ext import db
class Test(db.Model):
Name=db.StringProperty()
LastName=db.StringProperty()
class TestLoader(Loader):
def __init__(self):
Loader.__init__(
self,
'Test',
[('Name',str),
('LastName',str)]
)
loaders = [TestLoader]
Jonny, Lee Carl,Donny Nick,Cookie
C:\Program Files\Google>c:\Python25\python.exe google_appengine/bulkloader.py --filename=testapp/d.csv --kind=Test --url=http://localhost:8080/remote_api --config_file=testapp/uploader.py --app_id=fun-test