author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 23 Jul 2009 15:28:41 +0200 | |
changeset 2456 | aa25d6b244c8 |
parent 1977 | 606923dff11b |
child 2476 | 1294a6bdf3bf |
permissions | -rw-r--r-- |
0 | 1 |
"""cubicweb on appengine plugins for cubicweb-ctl |
2 |
||
3 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
9 |
||
1132 | 10 |
from os.path import exists, join, split, basename, normpath, abspath |
11 |
||
12 |
from logilab.common.clcommands import register_commands |
|
0 | 13 |
|
1138
22f634977c95
make pylint happy, fix some bugs on the way
sylvain.thenault@logilab.fr
parents:
1133
diff
changeset
|
14 |
from cubicweb import CW_SOFTWARE_ROOT, BadCommandUsage |
22f634977c95
make pylint happy, fix some bugs on the way
sylvain.thenault@logilab.fr
parents:
1133
diff
changeset
|
15 |
from cubicweb.toolsutils import (Command, copy_skeleton, create_symlink, |
22f634977c95
make pylint happy, fix some bugs on the way
sylvain.thenault@logilab.fr
parents:
1133
diff
changeset
|
16 |
create_dir) |
0 | 17 |
from cubicweb.cwconfig import CubicWebConfiguration |
18 |
||
19 |
from logilab import common as lgc |
|
20 |
from logilab import constraint as lgcstr |
|
21 |
from logilab import mtconverter as lgmtc |
|
22 |
import rql, yams, yapps, simplejson, dateutil, vobject, docutils, roman |
|
23 |
||
24 |
SLINK_DIRECTORIES = ( |
|
25 |
(lgc.__path__[0], 'logilab/common'), |
|
26 |
(lgmtc.__path__[0], 'logilab/mtconverter'), |
|
27 |
(lgcstr.__path__[0], 'logilab/constraint'), |
|
28 |
(rql.__path__[0], 'rql'), |
|
29 |
(simplejson.__path__[0], 'simplejson'), |
|
30 |
(yams.__path__[0], 'yams'), |
|
31 |
(yapps.__path__[0], 'yapps'), |
|
32 |
(dateutil.__path__[0], 'dateutil'), |
|
33 |
(vobject.__path__[0], 'vobject'), |
|
34 |
(docutils.__path__[0], 'docutils'), |
|
35 |
(roman.__file__.replace('.pyc', '.py'), 'roman.py'), |
|
36 |
||
37 |
(join(CW_SOFTWARE_ROOT, 'embedded', 'mx'), 'mx'), |
|
38 |
('/usr/share/fckeditor/', 'fckeditor'), |
|
39 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
40 |
(join(CW_SOFTWARE_ROOT, 'web', 'data'), join('cubes', 'shared', 'data')), |
0 | 41 |
(join(CW_SOFTWARE_ROOT, 'web', 'wdoc'), join('cubes', 'shared', 'wdoc')), |
42 |
(join(CW_SOFTWARE_ROOT, 'i18n'), join('cubes', 'shared', 'i18n')), |
|
43 |
(join(CW_SOFTWARE_ROOT, 'goa', 'tools'), 'tools'), |
|
44 |
(join(CW_SOFTWARE_ROOT, 'goa', 'bin'), 'bin'), |
|
45 |
) |
|
46 |
||
47 |
COPY_CW_FILES = ( |
|
48 |
'__init__.py', |
|
49 |
'__pkginfo__.py', |
|
50 |
'_exceptions.py', |
|
812 | 51 |
'appobject.py', |
0 | 52 |
'dbapi.py', |
53 |
'cwvreg.py', |
|
54 |
'cwconfig.py', |
|
713
5adb6d8e5fa7
update imports of "cubicweb.common.entity" and use the new module path "cubicweb.entity"
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
55 |
'entity.py', |
0 | 56 |
'interfaces.py', |
57 |
'rset.py', |
|
58 |
'schema.py', |
|
59 |
'schemaviewer.py', |
|
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
11
diff
changeset
|
60 |
'selectors.py', |
812 | 61 |
'utils.py', |
0 | 62 |
'vregistry.py', |
812 | 63 |
'view.py', |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
64 |
|
0 | 65 |
'common/mail.py', |
66 |
'common/migration.py', |
|
67 |
'common/mixins.py', |
|
68 |
'common/mttransforms.py', |
|
69 |
'common/uilib.py', |
|
812 | 70 |
|
71 |
'ext/html4zope.py', |
|
72 |
'ext/rest.py', |
|
0 | 73 |
|
74 |
'server/hookhelper.py', |
|
75 |
'server/hooksmanager.py', |
|
76 |
'server/hooks.py', |
|
77 |
'server/migractions.py', |
|
78 |
'server/pool.py', |
|
79 |
'server/querier.py', |
|
80 |
'server/repository.py', |
|
81 |
'server/rqlrewrite.py', |
|
82 |
'server/securityhooks.py', |
|
83 |
'server/session.py', |
|
84 |
'server/serverconfig.py', |
|
85 |
'server/ssplanner.py', |
|
86 |
'server/utils.py', |
|
87 |
'server/sources/__init__.py', |
|
88 |
||
89 |
'entities/__init__.py', |
|
90 |
'entities/authobjs.py', |
|
91 |
'entities/lib.py', |
|
92 |
'entities/schemaobjs.py', |
|
11
db9c539e0b1b
Add module wfobjs to enable workflow in gae.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3
diff
changeset
|
93 |
'entities/wfobjs.py', |
0 | 94 |
|
95 |
'sobjects/__init__.py', |
|
96 |
'sobjects/notification.py', |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
97 |
|
0 | 98 |
# XXX would be necessary for goa.testlib but require more stuff to be added |
99 |
# such as server.serverconfig and so on (check devtools.__init__) |
|
100 |
# 'devtools/__init__.py', |
|
101 |
# 'devtools/fake.py', |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
102 |
|
0 | 103 |
'web/__init__.py', |
104 |
'web/_exceptions.py', |
|
105 |
'web/action.py', |
|
106 |
'web/application.py', |
|
107 |
'web/box.py', |
|
108 |
'web/component.py', |
|
109 |
'web/controller.py', |
|
110 |
'web/form.py', |
|
111 |
'web/htmlwidgets.py', |
|
112 |
'web/httpcache.py', |
|
113 |
'web/request.py', |
|
114 |
'web/webconfig.py', |
|
115 |
'web/widgets.py', |
|
116 |
||
117 |
'web/views/__init__.py', |
|
118 |
'web/views/actions.py', |
|
119 |
'web/views/basecomponents.py', |
|
120 |
'web/views/basecontrollers.py', |
|
121 |
'web/views/baseforms.py', |
|
122 |
'web/views/basetemplates.py', |
|
123 |
'web/views/baseviews.py', |
|
124 |
'web/views/boxes.py', |
|
125 |
'web/views/calendar.py', |
|
126 |
'web/views/error.py', |
|
127 |
'web/views/editcontroller.py', |
|
128 |
'web/views/ibreadcrumbs.py', |
|
129 |
'web/views/idownloadable.py', |
|
130 |
'web/views/magicsearch.py', |
|
131 |
'web/views/management.py', |
|
132 |
'web/views/navigation.py', |
|
133 |
'web/views/startup.py', |
|
11
db9c539e0b1b
Add module wfobjs to enable workflow in gae.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3
diff
changeset
|
134 |
'web/views/vcard.py', |
0 | 135 |
'web/views/wdoc.py', |
136 |
'web/views/urlpublishing.py', |
|
137 |
'web/views/urlrewrite.py', |
|
138 |
'web/views/xbel.py', |
|
139 |
||
140 |
'wsgi/__init__.py', |
|
141 |
'wsgi/handler.py', |
|
142 |
'wsgi/request.py', |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
143 |
|
0 | 144 |
'goa/__init__.py', |
145 |
'goa/db.py', |
|
146 |
'goa/dbinit.py', |
|
147 |
'goa/dbmyams.py', |
|
148 |
'goa/goaconfig.py', |
|
149 |
'goa/goavreg.py', |
|
150 |
'goa/gaesource.py', |
|
151 |
'goa/rqlinterpreter.py', |
|
152 |
'goa/appobjects/__init__.py', |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
153 |
'goa/appobjects/components.py', |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
154 |
'goa/appobjects/dbmgmt.py', |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
155 |
'goa/appobjects/gauthservice.py', |
0 | 156 |
'goa/appobjects/sessions.py', |
157 |
||
158 |
'schemas/bootstrap.py', |
|
159 |
'schemas/base.py', |
|
160 |
) |
|
161 |
||
162 |
OVERRIDEN_FILES = ( |
|
163 |
('toolsutils.py', 'toolsutils.py'), |
|
164 |
('mttransforms.py', 'common/mttransforms.py'), |
|
165 |
('server__init__.py', 'server/__init__.py'), |
|
166 |
('rqlannotation.py', 'server/rqlannotation.py'), |
|
167 |
) |
|
168 |
||
169 |
||
170 |
def create_init_file(pkgdir, pkgname): |
|
171 |
open(join(pkgdir, '__init__.py'), 'w').write('"""%s pkg"""' % pkgname) |
|
172 |
||
173 |
||
174 |
class NewGoogleAppCommand(Command): |
|
175 |
"""Create a new google appengine application. |
|
176 |
||
177 |
<application directory> |
|
178 |
the path to the appengine application directory |
|
179 |
""" |
|
180 |
name = 'newgapp' |
|
181 |
arguments = '<application directory>' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
182 |
|
0 | 183 |
def run(self, args): |
184 |
if len(args) != 1: |
|
185 |
raise BadCommandUsage("exactly one argument is expected") |
|
186 |
appldir, = args |
|
187 |
appldir = normpath(abspath(appldir)) |
|
188 |
appid = basename(appldir) |
|
189 |
context = {'appname': appid} |
|
190 |
# goa application'skeleton |
|
191 |
copy_skeleton(join(CW_SOFTWARE_ROOT, 'goa', 'skel'), |
|
192 |
appldir, context, askconfirm=True) |
|
193 |
# cubicweb core dependancies |
|
194 |
for directory, subdirectory in SLINK_DIRECTORIES: |
|
195 |
subdirectory = join(appldir, subdirectory) |
|
196 |
if not exists(split(subdirectory)[0]): |
|
197 |
create_dir(split(subdirectory)[0]) |
|
198 |
create_symlink(directory, join(appldir, subdirectory)) |
|
199 |
create_init_file(join(appldir, 'logilab'), 'logilab') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1432
diff
changeset
|
200 |
# copy supported part of cubicweb |
0 | 201 |
create_dir(join(appldir, 'cubicweb')) |
202 |
for fpath in COPY_CW_FILES: |
|
203 |
target = join(appldir, 'cubicweb', fpath) |
|
204 |
if not exists(split(target)[0]): |
|
205 |
create_dir(split(target)[0]) |
|
206 |
create_symlink(join(CW_SOFTWARE_ROOT, fpath), target) |
|
207 |
# overriden files |
|
208 |
create_init_file(join(appldir, 'cubicweb/common'), 'cubicweb.common') |
|
209 |
for fpath, subfpath in OVERRIDEN_FILES: |
|
210 |
create_symlink(join(CW_SOFTWARE_ROOT, 'goa', 'overrides', fpath), |
|
211 |
join(appldir, 'cubicweb', subfpath)) |
|
212 |
# link every supported components |
|
3
512e9bd0685a
Renaming error in symlink creation for GOA.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
0
diff
changeset
|
213 |
packagesdir = join(appldir, 'cubes') |
11
db9c539e0b1b
Add module wfobjs to enable workflow in gae.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3
diff
changeset
|
214 |
create_init_file(join(appldir, 'cubes'), 'cubes') |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
11
diff
changeset
|
215 |
for include in ('addressbook','basket', 'blog','folder', |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
11
diff
changeset
|
216 |
'tag', 'comment', 'file', 'link', |
3
512e9bd0685a
Renaming error in symlink creation for GOA.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
0
diff
changeset
|
217 |
'mailinglist', 'person', 'task', 'zone', |
0 | 218 |
): |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
11
diff
changeset
|
219 |
create_symlink(CubicWebConfiguration.cube_dir(include), |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
11
diff
changeset
|
220 |
join(packagesdir, include)) |
0 | 221 |
# generate sample config |
222 |
from cubicweb.goa.goaconfig import GAEConfiguration |
|
223 |
from cubicweb.common.migration import MigrationHelper |
|
224 |
config = GAEConfiguration(appid, appldir) |
|
225 |
if exists(config.main_config_file()): |
|
226 |
mih = MigrationHelper(config) |
|
227 |
mih.rewrite_configuration() |
|
228 |
else: |
|
229 |
config.save() |
|
230 |
||
231 |
||
232 |
register_commands((NewGoogleAppCommand, |
|
233 |
)) |