[Zope3-Users] Prevent Duplicate Persistency
Mats Nordgren
mats at ronin-group.org
Wed Mar 15 09:54:29 EST 2006
This could be done by using the URL as the name for the Mark object.
from zope.app.container.contained import NameChooser
Class MarkNameChooser(NameChooser):
def chooseName(self, name, object):
name = object.url
self.checkName(name, object)
return name
<adapter
for=".interfaces.IMarkContainer"
provides="zope.app.container.interfaces.INameChooser"
factory=".bookmarks.MarkNameChooser" />
Make sure your Mark object is configured with set_before_add
<addform
...
set_before_add="url" />
-----Original Message-----
From: zope3-users-bounces at zope.org [mailto:zope3-users-bounces at zope.org] On
Behalf Of Dax
Sent: Tuesday, March 14, 2006 8:00 PM
To: zope3-users at zope.org
Subject: [Zope3-Users] Prevent Duplicate Persistency
For the following example (taken from "Zope3 In 30 Minutes"):
class IMark(Interface):
"""This is the book mark object."""
url = TextLine(
title=u"URL/Link",
description=u"URL of the website",
default=u"http://www.zope.org",
required=True)
description = Text(
title=u"Description",
description=u"Description of the website",
default=u"",
required=False)
How can I prevent Mark objects from having the same url? So if a Mark
object exists in BookMarker with Mark.url="http://www.zope.org/", how
can I prevent another Mark object from being added when its url is
"http://www.zope.org"?
Thanks.
_______________________________________________
Zope3-users mailing list
Zope3-users at zope.org
http://mail.zope.org/mailman/listinfo/zope3-users
More information about the Zope3-users
mailing list