Re: [Zope-dev] [BlueBream] disabling zope.schema constraint check in edit form

2011-08-19 Thread Joshua Immanuel
Hello Michael,

On Thu, 2011-08-18 at 12:46 +0200, Michael Howitz wrote:
> Some time a ago I wrote a blog post about objects with attributes
> which are unique in their container [1].
> Besides it is written in German you might get the clue from the code
> examples.
> 
> 
> [1]
> http://blog.gocept.com/zope3-objekte-mit-eindeutigen-titeln-innerhalb-eines-ordners
> 

Thanks for your excellent article. Google translate helped me to
understand your German text :)

Instead of going via the constraint approach I will try using your
approach. 

I see many people using z3c.form it makes me wonder whether to follow
their trail or to stick with zope.formlib. 

-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in


signature.asc
Description: This is a digitally signed message part
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] [BlueBream] disabling zope.schema constraint check in edit form

2011-08-18 Thread Charlie Clark
Am 18.08.2011, 13:19 Uhr, schrieb Joshua Immanuel :

> Yes. But considering the fact that I am doing this check at the
> interface level. I wonder if that is ever possible, because the
> constraint method knows just the value of the field.

You can always go from the field to the object to which it is bound. Not  
sure if your constraint is actually the best way to go.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] [BlueBream] disabling zope.schema constraint check in edit form

2011-08-18 Thread Joshua Immanuel
Hello Michael,

Thanks for the reply.

On Thu, 2011-08-18 at 12:46 +0200, Michael Howitz wrote:
> > Is there a way to disable the constraint check in the EditForm if
> > the 'name' field isn't modified?
> 
> Make sure your catalog search does not return the object you are
> currently editing.

Yes. But considering the fact that I am doing this check at the
interface level. I wonder if that is ever possible, because the
constraint method knows just the value of the field.

> > What is the preferred way of doing these kind of checks?
> 
> Some time a ago I wrote a blog post about objects with attributes
> which are unique in their container [1].
> Besides it is written in German you might get the clue from the code
> examples.
> 
> 
> [1]
> http://blog.gocept.com/zope3-objekte-mit-eindeutigen-titeln-innerhalb-eines-ordners

I'll check this and get back.

Regards
Joshua
-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in


signature.asc
Description: This is a digitally signed message part
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] [BlueBream] disabling zope.schema constraint check in edit form

2011-08-18 Thread Michael Howitz
Am 18.08.2011 um 09:59 schrieb Joshua Immanuel:
> Hello all,
> 
> I use the zope.schema field's constraint parameter to check for the
> uniqueness of a particular field like this
> 
>class IMyObject(Interface):
> 
>def check_for_uniqueness(value):
>cat = getUtility(ICatalog)
>results = cat.searchResults(object_name=value)
>for rslt in results:
>if rslt.name.lower() == value.lower():
>raise NameAlreadyExists(value)
>return True
> 
>name = TextLine(title=u'Name', required=True,
>   constraint=check_for_uniqueness)
>...
> 
> This goes well with the zope.formlib's AddForm.

As the value does not exist yet.

> But in edit form if I
> modify any other field other than the 'name' field I get the
> 'NameAlreadyExists' error.

As you find the object which you are editing in the catalog.

> Worse case scenario is where I have a cancel
> action button which just redirects to another page, that too screams for
> the NameAlreadyExists error.
> 
> Is there a way to disable the constraint check in the EditForm if the
> 'name' field isn't modified?

Make sure your catalog search does not return the object you are currently 
editing.

> What is the preferred way of doing these kind of checks?

Some time a ago I wrote a blog post about objects with attributes which are 
unique in their container [1].
Besides it is written in German you might get the clue from the code examples.


[1] 
http://blog.gocept.com/zope3-objekte-mit-eindeutigen-titeln-innerhalb-eines-ordners


Mit freundlichen Grüßen
-- 
Michael Howitz · m...@gocept.com · Softwareentwickler
gocept gmbh & co. kg · Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
http://gocept.com · Tel +49 345 1229889 8 · Fax +49 345 1229889 1
Zope- und Plone-Beratung und -Entwicklung

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )