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