Re: Do MappingStorage is able to solve conflicts

Éloi Rivard <[email protected]> Fri, 12 Oct 2018 08:46:21 -0700 (PDT)
Newsgroups gmane.comp.web.zope.zodb
Message-ID <[email protected]>
------=_Part_752_191166930.1539359181740
Content-Type: multipart/alternative; 
	boundary="----=_Part_753_1206953298.1539359181740"

------=_Part_753_1206953298.1539359181740
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I did not know about DemoStorage, it seems to do the job.

Thank you!

Le vendredi 12 octobre 2018 17:03:08 UTC+2, Jason Madden a =C3=A9crit :
>
> MappingStorage does not extend ConflictResolvingStorage and I wouldn't=20
> expect it to resolve conflicts.=20
>
> If you want an in-memory storage that does resolve conflicts, try=20
> DemoStorage (if not given a base or changes storage, it uses MappingStora=
ge=20
> objects).=20
>
> > On Oct 12, 2018, at 05:02, =C3=89loi Rivard <[email protected] <javascri=
pt:>>=20
> wrote:=20
> >=20
> > Hi. I have a very simple piece of code with a different behavior=20
> depending on it is running on a MappingStorage or a ClientStorage.=20
> Conflicts do not seem to be solved when I use a MappingStorage.=20
> >=20
> > import ZODB, transaction, persistent=20
> > from ZEO.ClientStorage import ClientStorage=20
> >=20
> > class MyMapping(persistent.mapping.PersistentMapping):=20
> >     def _p_resolveConflict(self, old, saved, new):=20
> >         return {"conflict": "happened"}=20
> >=20
> >=20
> > db =3D ZODB.DB(None)=20
> > #db =3D ZODB.DB(ClientStorage(("localhost", 9999)))=20
> > with db.transaction() as conn:=20
> >     conn.root.x =3D MyMapping()=20
> >=20
> > my_transaction_manager =3D transaction.TransactionManager()=20
> > conn1 =3D db.open(my_transaction_manager)=20
> > my_transaction_manager.commit()=20
> >=20
> > with db.transaction() as conn2:=20
> >     conn2.root.x["a"] =3D 1=20
> >=20
> > conn1.root.x["b"] =3D 2=20
> > my_transaction_manager.commit()=20
> >=20
> > This piece of code is stupid, but just shows that a conflict is raised=
=20
> with a MappingStorage, and not with a ClientStorage.=20
> >=20
> > =C3=89loi=20
> >=20
> > --=20
> > You received this message because you are subscribed to the Google=20
> Groups "zodb" group.=20
> > To unsubscribe from this group and stop receiving emails from it, send=
=20
> an email to [email protected] <javascript:>.=20
> > For more options, visit https://groups.google.com/d/optout.=20
>
>

--=20
You received this message because you are subscribed to the Google Groups "=
zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

------=_Part_753_1206953298.1539359181740
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I did not know about DemoStorage, it seems to do the =
job.</div><div><br></div><div>Thank you!<br></div><br>Le vendredi 12 octobr=
e 2018 17:03:08 UTC+2, Jason Madden a =C3=A9crit=C2=A0:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;">MappingStorage does not extend ConflictResolvingSt=
orage and I wouldn&#39;t expect it to resolve conflicts.
<br>
<br>If you want an in-memory storage that does resolve conflicts, try DemoS=
torage (if not given a base or changes storage, it uses MappingStorage obje=
cts).
<br>
<br>&gt; On Oct 12, 2018, at 05:02, =C3=89loi Rivard &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"eLp1ys2qBAAJ" rel=3D"nofol=
low" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=
=3D"this.href=3D&#39;javascript:&#39;;return true;">[email protected]</a>&gt=
; wrote:
<br>&gt;=20
<br>&gt; Hi. I have a very simple piece of code with a different behavior d=
epending on it is running on a MappingStorage or a ClientStorage. Conflicts=
 do not seem to be solved when I use a MappingStorage.
<br>&gt;=20
<br>&gt; import ZODB, transaction, persistent
<br>&gt; from ZEO.ClientStorage import ClientStorage
<br>&gt;=20
<br>&gt; class MyMapping(persistent.mapping.<wbr>PersistentMapping):
<br>&gt; =C2=A0 =C2=A0 def _p_resolveConflict(self, old, saved, new):
<br>&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 return {&quot;conflict&quot;: &quot;ha=
ppened&quot;}
<br>&gt;=20
<br>&gt;=20
<br>&gt; db =3D ZODB.DB(None)
<br>&gt; #db =3D ZODB.DB(ClientStorage((&quot;<wbr>localhost&quot;, 9999)))
<br>&gt; with db.transaction() as conn:
<br>&gt; =C2=A0 =C2=A0 conn.root.x =3D MyMapping()
<br>&gt;=20
<br>&gt; my_transaction_manager =3D transaction.<wbr>TransactionManager()
<br>&gt; conn1 =3D db.open(my_transaction_<wbr>manager)
<br>&gt; my_transaction_manager.commit(<wbr>)
<br>&gt;=20
<br>&gt; with db.transaction() as conn2:
<br>&gt; =C2=A0 =C2=A0 conn2.root.x[&quot;a&quot;] =3D 1
<br>&gt;=20
<br>&gt; conn1.root.x[&quot;b&quot;] =3D 2
<br>&gt; my_transaction_manager.commit(<wbr>)
<br>&gt;=20
<br>&gt; This piece of code is stupid, but just shows that a conflict is ra=
ised with a MappingStorage, and not with a ClientStorage.
<br>&gt;=20
<br>&gt; =C3=89loi
<br>&gt;=20
<br>&gt; --=20
<br>&gt; You received this message because you are subscribed to the Google=
 Groups &quot;zodb&quot; group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an email to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-m=
ailto=3D"eLp1ys2qBAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;re=
turn true;">zodb+uns...@googlegroups.<wbr>com</a>.
<br>&gt; For more options, visit <a href=3D"https://groups.google.com/d/opt=
out" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;htt=
ps://groups.google.com/d/optout&#39;;return true;" onclick=3D"this.href=3D&=
#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.go=
ogle.com/d/<wbr>optout</a>.
<br>
<br></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;zodb&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">zodb+unsubscri=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

------=_Part_753_1206953298.1539359181740--

------=_Part_752_191166930.1539359181740--