今天我们站点上出现了个跟国名有关的错误。一个来自”The Federated States of Micronesia”的老兄试图给我们站点留言。我们的IP2Location解析了他的ip并且得到了正确的国家名称”MICRONESIA, FEDERATED STATES OF”。可是我们的数据库country字段的限制是20,最终还是把这位老兄的留言拒之门外了。。。(小国家真不容易,这样也能被拒绝,我估计这老兄一定这么想。)
这让我想起了个问题,不知道世界上最长的国家名称能有多少个字符?
写个blog纪念一下这位老兄的国家吧,也算长见识了。
http://en.wikipedia.org/wiki/Federated_States_of_Micronesia
Python
Django, life, Python
今天checkout最新的satchmo看了一下,发现变化还是很大的。看样子我们的BE是没法升级到最新的satchmo了…
还没有时间仔细研究,不过发现有几个satchmo用到的第三方的app值得注意一下:
1. django-registration
http://code.google.com/p/django-registration/
这个已经用过几次,感觉不错,而且感觉它的生命力很强。
2. django-values
http://code.google.com/p/django-values/
satchmo用这个替换了原来自己写的configuration模块。我一直认为satchmo的configuration模块有设计上的缺陷,结果这次被彻底换掉了,不错。有时间研究一下这个。
3. threaded_multihost
http://gosatchmo.com/apps/django-threaded-multihost/
multi-site aware features, 不是很懂,还得看看代码。
Python
Django, satchmo
I want to share a directory structure comes from my Django project.
Here is basic structure:
/PROJECT/manage.py (under svn)
/PROJECT/__init__.py (under svn)
/PROJECT/urls.py (under svn)
/PROJECT/settings.py (under svn)
/PROJECT/local_settings.py (not under svn)
/PROJECT/env.sh (not under svn)
/PROJECT/run (not under svn)
/PROJECT/apps (under svn)
/PROJECT/docs (under svn)
/PROJECT/static (under svn)
/PROJECT/templates (under svn)
/PROJECT/tests (under svn)
/PROJECT/scripts (under svn)
/PROJECT/initial_data (under svn)
/PROJECT/middlewares (under svn)
/PROJECT/patches (under svn)
/PROJECT/logs (not under svn)
/PROJECT/tmp (not under svn)
Here is the detail for each item.
- manage.py and __init__.py are default, you don’t need to change them.
- urls.py. Actually, we didn’t not write the url patterns in this file, we just include the url patterns from apps.urls in this file
- settings.py and local_settings.py. You must import local_settings.py from settings.py. In the settings.py, you have generic configuration. So you can add this file in the subversion. For in local_settings.py, we will put some particular settings based different environment. You don’t need to worry about breaking other’s environment by checking in the settings.py file any more.
- env.sh. This is a key file in this structure. With my experience, some rookies are always bothered by kinds of module not found issues. In this file you need at least add these two environment variable. They’re PYTHONPATH and DJANGO_SETTINGS_MODULE. I always add a PROJECT_HOME variable, and then I can use this later in my shell scripts. That’s very very useful.
- run. This a shell wrapping of manage.py. That’s because you always need some environment setup before you run the manage.py. Here is a example
PYTHONPATH=$PROJECT_HOME:$PYTHONPATH
DJANGO_SETTINGS_MODULE=settings
python2.5 manage.py $*
- apps directory, it’s the directory hold all of the apps.
- docs, we always put kinds of document about the project here, such as deploy document
- static directory, the static pages are always located here.
- templates, we put template here.
- tests, we plan to put the QA’s test cases there. We also will put some unit test there.
- scripts, some dba scripts located here.
- initial_data: The basic database of the site.
- patches and tmp directory is rarely used.
Python
Django, Python
Recent Comments