Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lc_ldap
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hamza Dely
lc_ldap
Commits
629310d3
Commit
629310d3
authored
Nov 09, 2014
by
Valentin Samir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[objets, attributs] Vérification de l'absence de modif concurrente après acquisition du lock
et ajout de historique à concurrent=False
parent
494cd42d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
attributs.py
attributs.py
+3
-2
objets.py
objets.py
+14
-11
No files found.
attributs.py
View file @
629310d3
...
...
@@ -255,7 +255,7 @@ class Attr(object):
optional
=
True
conn
=
None
unique
=
False
concurent
=
True
concur
r
ent
=
True
unique_exclue
=
[]
#: Le nom de l'attribut dans le schéma LDAP
ldap_name
=
None
...
...
@@ -852,7 +852,7 @@ class droits(Attr):
class
solde
(
floatAttr
):
python_type
=
float
singlevalue
=
True
concurent
=
False
concur
r
ent
=
False
optional
=
True
legend
=
u
"Solde d'impression"
can_modify
=
[
imprimeur
,
nounou
,
tresorier
]
...
...
@@ -1306,6 +1306,7 @@ class historique(Attr):
"""Un historique est usuellement de la forme JJ/MM/AAAA HH:mm:ss, action comm"""
singlevalue
=
False
concurrent
=
False
optional
=
True
legend
=
u
"Historique de l'objet"
category
=
'info'
...
...
objets.py
View file @
629310d3
...
...
@@ -594,14 +594,17 @@ class CransLdapObject(object):
cranslib
.
deprecated
.
usage
(
"Des locks ne devrait être ajoutés que dans un context manager"
,
level
=
2
)
self
.
conn
.
lockholder
.
addlock
(
attr
,
str
(
attribut
),
self
.
lockId
)
locked
.
append
((
attr
,
str
(
attribut
),
self
.
lockId
))
# On lock si l'attribut ne supporte pas les modifications concurente (comme pour le solde) si :
# * on effectue réellement un modification sur l'attribut
# * on a pas déjà effectuer un modification qui nous a déjà fait acquérir le lock
if
not
attribut
.
concurent
and
self
.
_modifs
.
get
(
attr
,
[])
==
self
.
attrs
.
get
(
attr
,
[])
and
attrs_before_verif
!=
self
.
attrs
.
get
(
attr
,
[]):
if
not
self
.
in_context
:
cranslib
.
deprecated
.
usage
(
"Des locks ne devrait être ajoutés que dans un context manager"
,
level
=
2
)
self
.
conn
.
lockholder
.
addlock
(
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
)
locked
.
append
((
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
))
# On lock si l'attribut ne supporte pas les modifications concurrente (comme pour le solde) si :
# * on effectue réellement un modification sur l'attribut
# * on a pas déjà effectuer un modification qui nous a déjà fait acquérir le lock
if
not
attributs
.
AttributeFactory
.
get
(
attr
).
concurrent
and
self
.
_modifs
.
get
(
attr
,
[])
==
self
.
attrs
.
get
(
attr
,
[])
and
attrs_before_verif
!=
self
.
attrs
.
get
(
attr
,
[]):
if
not
self
.
in_context
:
cranslib
.
deprecated
.
usage
(
"Des locks ne devrait être ajoutés que dans un context manager"
,
level
=
2
)
self
.
conn
.
lockholder
.
addlock
(
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
)
locked
.
append
((
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
))
# une fois le lock acquit, on vérifie que l'attribut n'a pas été édité entre temps
if
self
.
conn
.
search
(
dn
=
self
.
dn
,
scope
=
0
)[
0
].
get
(
attr
,
[])
!=
self
.
attrs
.
get
(
attr
,
[]):
raise
ldap_locks
.
LockError
(
"L'attribut %s a été modifié dans la base ldap avant l'acquisition du lock"
%
attr
)
except
ldap_locks
.
LockError
:
# Si on ne parvient pas à prendre le lock pour l'une des valeurs
# on libère les locks pris jusque là et on propage l'erreur
...
...
@@ -614,9 +617,9 @@ class CransLdapObject(object):
for
attribut
in
self
.
_modifs
.
get
(
attr
,
[]):
if
attribut
.
unique
and
not
attribut
in
attrs_before_verif
and
not
attribut
in
attribut
.
unique_exclue
:
self
.
conn
.
lockholder
.
removelock
(
attr
,
str
(
attribut
),
self
.
lockId
)
# Si on remet la valeur antérieure au lock, on le libère
if
not
attribut
.
concu
rent
and
self
.
_modifs
.
get
(
attr
,
[])
!=
self
.
attrs
.
get
(
attr
,
[])
and
attrs_before_verif
==
self
.
attrs
.
get
(
attr
,
[]):
self
.
conn
.
lockholder
.
removelock
(
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
)
# Si on remet la valeur antérieure au lock, on le libère
if
not
attributs
.
AttributeFactory
.
get
(
attr
).
concur
rent
and
self
.
_modifs
.
get
(
attr
,
[])
!=
self
.
attrs
.
get
(
attr
,
[])
and
attrs_before_verif
==
self
.
attrs
.
get
(
attr
,
[]):
self
.
conn
.
lockholder
.
removelock
(
"dn"
,
"%s_%s"
%
(
self
.
dn
.
replace
(
'='
,
'-'
).
replace
(
','
,
'_'
),
attr
),
self
.
lockId
)
# On met à jour self._modifs avec les nouvelles valeurs
self
.
_modifs
[
attr
]
=
attrs_before_verif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment