继续昨天的折腾《折腾下ELLA(1)》……
很遗憾,晚上还是断线了,PIP没有成功安装ELLA。
今天利用公司的网络,把ELLA安装了进去。在VirtualEnv下,ELLA在Lib\site-package下创建一个ELLA的连接,文件名是:ella.egg-link。里面的内容是类似于:
D:\xx\xx\ur-virtual-directory\src\ella
如上所示,ELLA的实际文件就在ur-virtual-directory\src中。
非常奇怪的是,在VirtualEnv中,path貌似是默认使用的系统中设定的那个。在命令行的session中path之后,即便是添加上Scripts目录,在site-packages里面的包也不能被找到。只好按照老办法把上面的包,都复制到项目目录下。
经过这一系列折腾,要运行ELLA,实际需要的库文件包,包括:anyjson、django、djangomarkup、MySQLdb、PIL。如果使用SQLite3,可以不要MySQLdb。
后续的操作如下(1-5见上篇):
6、
pip install anyjson
7、
cd src
../scripts/django-admin.py startproject demo
从site-packages下复制anyjson、django、djangomarkup到src/demo下;从src中复制ella/ella,djangomarkup/djangomarkup到demo下(也可先export后再复制,这样可以不带git的缓存信息);复制MySQLdb、PIL到src/demo(我是之前已经在原来的Python环境中已经安装,位置在site-packages下)。
8、参照教程,修改Settings.py
顶部添加内容:
from os.path import join, dirname
PROJECT_ROOT = dirname(__file__)
中间修改内容:
MEDIA_ROOT = join(PROJECT_ROOT, 'static')
MEDIA_URL = '/static/'
TEMPLATE_DIRS = (
join(PROJECT_ROOT, 'templates'),
)
配置数据库:
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'demo' # Or path to database file if using sqlite3.
DATABASE_USER = 'name' # Not used with sqlite3.
DATABASE_PASSWORD = 'password' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
后面添加内容:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.redirects',
'ella.core',
'ella.photos',
'ella.newman',
'ella.articles',
'djangomarkup',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.media',
'django.core.context_processors.auth',
'django.core.context_processors.request',
'ella.newman.context_processors.newman_media',
)
NEWMAN_MEDIA_PREFIX = MEDIA_URL + 'newman/'
DEFAULT_MARKUP = 'markdown'
修改url.py,直接把下面的内容全部覆盖到Url.py中即可。
from django.conf.urls.defaults import *
from django.conf import settings
from ella import newman
# make sure to import ella error handlers
from ella.core.urls import handler404, handler500
# register ella's admin
newman.autodiscover()
urlpatterns = patterns('',)
if settings.DEBUG:
# only use these urls in DEBUG mode, otherwise they should be handled by your web server
from os.path import dirname, join, normpath
import django, ella
# static files from both admin apps
ADMIN_ROOTS = (
normpath(join(dirname(ella.__file__), 'newman', 'media')),
normpath(join(dirname(django.__file__), 'contrib', 'admin', 'media')),
)
# serve static files
urlpatterns += patterns('',
# newman specific files first
(r'^%s/(?P<path>.*)$' % settings.NEWMAN_MEDIA_PREFIX.strip('/'), 'ella.utils.views.fallback_serve', {'document_roots': ADMIN_ROOTS}),
# rest of the static files
(r'^%s/(?P<path>.*)$' % settings.MEDIA_URL.strip('/'), 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
)
# actual URL mappings
urlpatterns += patterns('',
(r'^newman/', include(newman.site.urls)),
(r'^', include('ella.core.urls')),
)
9、回到VirtualEnv的命令行(其实已经和VirtualEnv没啥关系了哈),
cd demo
manage.py syncdb
##此处提示输入管理员密码,按照提示搞定即可##
manage.py runserver
10、OK。服务启动,默认访问地址在命令行中有给出,http://127.0.0.1:8000/ 感觉很棒!截张图显摆一下。
界面很舒服,我所需要的大部分功能都有了。正在熟悉ELLA的程序结构、数据结构,尝试看看如何扩展开发。
Good Luck!

0 评论:
发表评论