笔者所在的小组负责SaaS开发,几乎承载了中心的全部SaaS需求。其中,有长期维护的重点项目,也有短期突击的演示项目,每个人都身兼数职。当然,开发平台也开放给其他人员使用,整个平台有着成百上千的SaaS应用。这些应用中存在大量重复的功能块,重复的开发工作。随着开发平台的建设,部分功能被沉淀到平台组件,笔者希望另一部分也能够复用。一方面可以减轻开发任务,另一方面是有利于功能解耦和维护。由于平台提供的开发框架是Django,本文主要讨论构建可重用Django APP的原则和相关事项。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
import os
from setuptools import find_packages, setup
from pip.req import parse_requirements
install_reqs = parse_requirements('requirements.txt', session='hack')
# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
    README = readme.read()

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
    name='django-app-template',
    version='0.0.1',
    author='',
    author_email='@gmail.com',
    description='django-app-template',
    long_description=README,
    keywords='django app',
    license='BSD License',
    url='http://django-app-template.com/',

    packages=find_packages(exclude=[]),
    include_package_data=True,
    zip_safe=False,
	install_requires=reqs,

    classifiers=[
        'Environment :: Web Environment',
        'Framework :: Django',
        'Framework :: Django :: 1.8',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Topic :: Internet :: WWW/HTTP',
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
    ],
)