author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 28 Feb 2011 14:14:19 +0100 | |
branch | stable |
changeset 7032 | b712477ae286 |
parent 7026 | 2c65dd2cbfff |
child 7034 | 1ac9715876e3 |
permissions | -rw-r--r-- |
7026
2c65dd2cbfff
[migration] missing future import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6955
diff
changeset
|
1 |
from __future__ import with_statement |
7032
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
2 |
|
6955
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
if confirm('fix existing cwuri?'): |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
from logilab.common.shellutils import ProgressBar |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
from cubicweb.server.session import hooks_control |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
rset = rql('Any X, XC WHERE X cwuri XC, X cwuri ~= "%/eid/%"') |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
pb = ProgressBar(nbops=rset.rowcount, size=70) |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
with hooks_control(session, session.HOOKS_DENY_ALL, 'integrity'): |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
for i, e in enumerate(rset.entities()): |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
e.set_attributes(cwuri=e.cwuri.replace('/eid', '')) |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
if i % 100: # commit every 100 entities to limit memory consumption |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
commit(ask_confirm=False) |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
pb.update() |
a6c32edabc8d
[entity, metadata] huuum, use resolvable url as cwuri... And fix existing ones.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
commit(ask_confirm=False) |
7032
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
15 |
|
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
16 |
try: |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
17 |
from cubicweb import devtools |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
18 |
option_group_changed('anonymous-user', 'main', 'web') |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
19 |
option_group_changed('anonymous-password', 'main', 'web') |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
20 |
except ImportError: |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
21 |
# cubicweb-dev unavailable, nothing needed |
b712477ae286
[config] fix option group clash causing anonymous user configuration to end in the MAIN section instead of the WEB section if cubicweb-dev is installed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7026
diff
changeset
|
22 |
pass |