[Zope3-Users] Re: Strange ZODB error - Solved: Zalchemy bug

2007-08-13 Thread Christian Zagrodnick
On 2007-08-09 17:21:57 +0200, Christian Zagrodnick 
[EMAIL PROTECTED] said:


On 2007-08-09 16:27:23 +0200, Hermann Himmelbauer 
[EMAIL PROTECTED] said:



Am Donnerstag, 9. August 2007 15:44 schrieb Hermann Himmelbauer:

Hi,
After updating some z3c packages and changing some of my code, I recei

ve a

very strange traceback from Zope3:


Ah, after fiddling around I found out that the svn update of the 
zalchemy package resulted in this error. If somewhere in my code 
zalchemy is used, the TypeError emerges. It seems that recently there 
was a change to the zalchemy package (svn log):


---

-

r78682 | zagy | 2007-08-08 10:53:01 +0200 (Mi, 08 Aug 2007) | 1 line

using the threadlocal strategy of sqlalchemy instead of creating one en

gine per

thread. This allows connection pooling for instance.
---

-


I reverted zalchemy to an older version an all is well again.


Interesting. I wonder why this happens. I'll try to reproduce.


So it happend when the ZAlchemy engine was used as a local utility. 
Hermann, could you check if it works now?





--
Christian Zagrodnick

gocept gmbh  co. kg  ·  forsterstrasse 29 · 06112 halle/saale
www.gocept.com · fon. +49 345 12298894 · fax. +49 345 12298891



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: zopeproject zcml problem

2007-08-13 Thread Philipp von Weitershausen

Andrew Rodriguez wrote:

I was trying to use zopeproject, but when I have any zcml,
and I run ./bin/paster serve deploy.ini, I get a ConfigurationError.

The error:
  ...
  File /Library/Frameworks/Python.framework/Versions/2.4/lib/
  python2.4/site-packages/zope.configuration-3.4.0b1-py2.4.egg/
  zope/configuration/config.py, line 485, in factory
raise ConfigurationError(Unknown directive, ns, n)
  zope.configuration.xmlconfig.ZopeXMLConfigurationError : File 
/Users/andrew/biblioteca/site.zcml, line 4.2-4.34
ZopeXMLConfigurationError: File 
/Users/andrew/biblioteca/biblioteca/configure.zcml, line 5.2-5.37
ZopeXMLConfigurationError: File 
/Users/andrew/biblioteca/biblioteca/permissions.zcml, line 3.2
ConfigurationError: ('Unknown directive', 
u'http://namespaces.zope.org/zope', u'permission')


And my permission.zcml:

configure xmlns=http://namespaces.zope.org/zope;
  permission
  id=library.ViewBooks
  title=View books
  /
 ...

This happens with every thing, even simple things such as class ...,
so my question would be how would I get paster to recognize them.


Where and how are you including permission.zcml? Order matters with ZCML.


--
http://worldcookery.com -- Professional Zope documentation and training

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: z3c.form, applyChanges, IModifiedEvent

2007-08-13 Thread Philipp von Weitershausen

Darryl Cousins wrote:

Following a post on grok-dev I learnt about additional arguments to
ModifiedEvent.

http://mail.zope.org/pipermail/grok-dev/2007-August/001807.html

By changing z3c.form.form.applyChanges to return a dictionary of
interfaces and names of the attributes changed (instead of the current
bool value) then I can easily create the correct additional attributes
within the applyChanges method of EditForm:


...

Sadly, zope.formlib doesn't send this info along either, therefore 
setting a bad example. I filed 
https://bugs.launchpad.net/zope3/+bug/98483 a while ago, just never got 
around to fix it... Thanks for reminding.





def applyChanges(form, content, data):
changes = {}
for name, field in form.fields.items():
# If the field is not in the data, then go on to the next one
if name not in data:
continue
# Get the datamanager and get the original value
dm = zope.component.getMultiAdapter(
(content, field.field), IDataManager)
oldValue = dm.get()
# Only update the data, if it is different
if dm.get() != data[name]:
dm.set(data[name])
# get the interface and collect changed attribute names
changes.setdefault(dm.field.interface, []).append(name)
return changes


class EditForm(Form):



def applyChanges(self, data):
   content = self.getContent()
   changes = applyChanges(self, content, data)
   if changes: # testing a dict as a bool is prone to error???
   descriptions = []
   for interface, names in changes.items():
   descriptions.append(zope.lifecycleevent.Attributes(interface,
*names))
   zope.event.notify(
zope.lifecycleevent.ObjectModifiedEvent(content, *descriptions))
   return changes

Hopefully pypi will be back up again later today so I can do a fresh
build of z3c.form and run the tests with my changes as set out above.

Best regards,
Darryl Cousins



--
http://worldcookery.com -- Professional Zope documentation and training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Strange ZODB error - Solved: Zalchemy bug

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 08:10 schrieb Christian Zagrodnick:
 On 2007-08-09 17:21:57 +0200, Christian Zagrodnick

 [EMAIL PROTECTED] said:
  On 2007-08-09 16:27:23 +0200, Hermann Himmelbauer
 
  [EMAIL PROTECTED] said:
  Am Donnerstag, 9. August 2007 15:44 schrieb Hermann Himmelbauer:
  Hi,
  After updating some z3c packages and changing some of my code, I recei
 
  ve a
 
  very strange traceback from Zope3:
 
  Ah, after fiddling around I found out that the svn update of the
  zalchemy package resulted in this error. If somewhere in my code
  zalchemy is used, the TypeError emerges. It seems that recently there
  was a change to the zalchemy package (svn log):
 
  ---
 
  -
 
  r78682 | zagy | 2007-08-08 10:53:01 +0200 (Mi, 08 Aug 2007) | 1 line
 
  using the threadlocal strategy of sqlalchemy instead of creating one en
 
  gine per
 
  thread. This allows connection pooling for instance.
  ---
 
  -
 
  I reverted zalchemy to an older version an all is well again.
 
  Interesting. I wonder why this happens. I'll try to reproduce.

 So it happend when the ZAlchemy engine was used as a local utility.

Yes, that's right.

 Hermann, could you check if it works now?

I updated zalchemy it to the current SVN-Version, but it does still not work. 
However, the error message is different and a lot more verbose:

--
2007-08-13T11:01:03 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 
{'fp_name1': 'A%'}
2007-08-13 11:01:03,777 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 
COMMIT
--
2007-08-13T11:01:03 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 COMMIT
--
2007-08-13T11:01:03 CRITICAL txn.1082132800 A storage error occurred during 
the second phase of the two-phase commit.  Resources may be in an 
inconsistent state.
--
2007-08-13T11:01:03 ERROR txn.1082132800 Error in tpc_abort() on manager 
z3c.zalchemy.datamanager.AlchemyDataManager object at 0x42b30d0
Traceback (most recent call last):
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 462, in _cleanup
rm.tpc_abort(self)
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 222, in tpc_abort
self._cleanup()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 236, in _cleanup
util._resetEngine()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 64, in _resetEngine
self.engine = None
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
927, in register
self._register(obj)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
937, in _register
self.transaction_manager.get().join(self)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 222, in join
raise ValueError(expected txn status %r or %r, but it's %r % (
ValueError: expected txn status 'Active' or 'Doomed', but it's 'Committing'
--
2007-08-13T11:01:03 ERROR txn.1082132800 Failed to abort resource manager: 
z3c.zalchemy.datamanager.AlchemyDataManager object at 0x42b30d0
Traceback (most recent call last):
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 476, in abort
rm.abort(self)
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 205, in abort
self._cleanup()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 236, in _cleanup
util._resetEngine()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 64, in _resetEngine
self.engine = None
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
927, in register
self._register(obj)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
937, in _register
self.transaction_manager.get().join(self)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 216, in join
self._prior_operation_failed() # doesn't return
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 210, in _prior_operation_failed
raise TransactionFailedError(An operation previously failed, 
TransactionFailedError: An operation previously failed, with traceback:

  File /local/home/dusty/python/Python-2.4.4/lib/python2.4/threading.py, 
line 442, in __bootstrap
self.run()
  File /local/home/dusty/python/Python-2.4.4/lib/python2.4/threading.py, 
line 422, in run
self.__target(*self.__args, **self.__kwargs)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/twisted/python/threadpool.py, 
line 148, in _worker
context.call(ctx, function, *args, **kwargs)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/twisted/python/context.py, 
line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File 

[Zope3-Users] Invariants and forms

2007-08-13 Thread NYLAN
Hello, I'm using an invariant to check if given passwords are equal.

I've found two different examples(see below), but both don't display my given 
exception message. The only thing i get is the standard error message.

Since this is my first experience with zope, could someone explain to me the 
correct way to get a custom error message with invariants?

Thanks!!!
I'm using zope version 3.3.1.

First example
(taken from: 
http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-in-interfaces-mit-zope-formlib/):

class PasswordsAreNotEqual(zope.schema.ValidationError):
uDas Passwort und die Wiederholung sind nicht gleich.
zope.interface.implements(zope.app.form.interfaces.IWidgetInputError)

def arePasswordsEqual(obj)
if obj.password != obj.password2:
raise PasswordsAreNotEqual

from zope.interface import Interface, invariant

class IUser(Interface):
password = zope.schema.Password(title=uPasswort)
password2 = zope.schema.Password(title=uWiederholung des Passworts)

arePasswordsEqual = invariant(arePasswordsEqual)


Second example
(taken from:
http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-invariants-in-interfaces-mit-zope-formlib-aktualisiert)

import zope.interface

class IUser(zope.interface.Interface):
password = zope.schema.Password(title=uPasswort)
password2 = zope.schema.Password(title=uWiederholung des Passworts)

@zope.interface.invariant
def arePasswordsEqual(user):
if user.password != user.password2:
raise zope.interface.Invalid(
uDas Passwort und die Wiederholung sind nicht gleich.)
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Invariants and forms

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 12:01 schrieb Darryl Cousins:
 Hi,

 This was answered recently me thinks.

 http://mail.zope.org/pipermail/zope3-users/2007-August/006648.html

I think this covers a z3c.form-related issue, but not formlib...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Invariants and forms

2007-08-13 Thread Darryl Cousins
Hi,

This was answered recently me thinks.

http://mail.zope.org/pipermail/zope3-users/2007-August/006648.html

Regards,
Darryl

On Mon, 2007-08-13 at 11:37 +0200, [EMAIL PROTECTED] wrote:
 Hello, I'm using an invariant to check if given passwords are equal.
 
 I've found two different examples(see below), but both don't display my given 
 exception message. The only thing i get is the standard error message.
 
 Since this is my first experience with zope, could someone explain to me the 
 correct way to get a custom error message with invariants?
 
 Thanks!!!
 I'm using zope version 3.3.1.
 
 First example
 (taken from: 
 http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-in-interfaces-mit-zope-formlib/):
 
 class PasswordsAreNotEqual(zope.schema.ValidationError):
 uDas Passwort und die Wiederholung sind nicht gleich.
 zope.interface.implements(zope.app.form.interfaces.IWidgetInputError)
 
 def arePasswordsEqual(obj)
 if obj.password != obj.password2:
 raise PasswordsAreNotEqual
 
 from zope.interface import Interface, invariant
 
 class IUser(Interface):
 password = zope.schema.Password(title=uPasswort)
 password2 = zope.schema.Password(title=uWiederholung des Passworts)
 
 arePasswordsEqual = invariant(arePasswordsEqual)
 
 
 Second example
 (taken from:
 http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-invariants-in-interfaces-mit-zope-formlib-aktualisiert)
 
 import zope.interface
 
 class IUser(zope.interface.Interface):
 password = zope.schema.Password(title=uPasswort)
 password2 = zope.schema.Password(title=uWiederholung des Passworts)
 
 @zope.interface.invariant
 def arePasswordsEqual(user):
 if user.password != user.password2:
 raise zope.interface.Invalid(
 uDas Passwort und die Wiederholung sind nicht gleich.)

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Strange ZODB error - Solved: Zalchemy bug

2007-08-13 Thread Benji York

Hermann Himmelbauer wrote:
2007-08-13T11:01:03 CRITICAL txn.1082132800 A storage error occurred during 
the second phase of the two-phase commit.  Resources may be in an 
inconsistent state.


I don't know the details, but doesn't Zalchemy do some interesting 
things relating to transactions?

--
Benji York
Senior Software Engineer
Zope Corporation
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: z3c.form, applyChanges, IModifiedEvent

2007-08-13 Thread Stephan Richter
On Sunday 12 August 2007 17:31, Darryl Cousins wrote:
 Following a post on grok-dev I learnt about additional arguments to
 ModifiedEvent.

 http://mail.zope.org/pipermail/grok-dev/2007-August/001807.html

 By changing z3c.form.form.applyChanges to return a dictionary of
 interfaces and names of the attributes changed (instead of the current
 bool value) then I can easily create the correct additional attributes
 within the applyChanges method of EditForm:

I checked in the new feature into the z3c.form trunk. It will be part of the 
next release.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - how to raise/create an error in an action?

2007-08-13 Thread Hermann Himmelbauer
Hi,
I have a case where an error may occur in the form-action method (z3c.form, 
not formlib!), e.g. when data is not found in my database. I'd then like to 
output this error, similar when a widget error occurs. Moreover there are two 
simple cases:

1) Errors that are related to a widget (hence the error should be shown along 
with the widget)
2) Errors which are unrelated to the widget (like an Invariant).

Is there a simple way to accomplish this?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Strange ZODB error - Solved: Zalchemy bug

2007-08-13 Thread Jürgen Kartnaller

I don't think the recent change to the utility is correct.

Because the engine property is now volatile it needs to be recreated any 
time the utility is garbage collected.


Maybe that's the reason for these strange things to happen.

Jürgen


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - how to raise/create an error in an action?

2007-08-13 Thread Stephan Richter
On Monday 13 August 2007 12:02, Hermann Himmelbauer wrote:
 I have a case where an error may occur in the form-action method (z3c.form,
 not formlib!), e.g. when data is not found in my database. I'd then like to
 output this error, similar when a widget error occurs. Moreover there are
 two simple cases:

 1) Errors that are related to a widget (hence the error should be shown
 along with the widget)
 2) Errors which are unrelated to the widget (like an Invariant).

Hi Hermann,

could you elaborate a little bit more? I think a step-by-step description of 
how *you* envision it to work would be great as well as a very specific use 
case of what you are trying to do.

My initial reaction is: This really needs to be supported by the API. Once I 
have more details, I will either implement an API for this or give you a 
response on how to do it in your code.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Invariants and forms

2007-08-13 Thread Stephan Richter
On Monday 13 August 2007 12:55, Nylan wrote:
 It's a relative big project and I'm using formlib, so changing to z3c.form
 (with resolved issue) is not possible at the moment.

I'll note that unless you have a lot of formlib customization, switching 
should not be that hard.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Invariants and forms

2007-08-13 Thread Stephan Richter
On Monday 13 August 2007 05:37, [EMAIL PROTECTED] wrote:
 Since this is my first experience with zope, could someone explain to me
 the correct way to get a custom error message with invariants?

I am not sure how or whether formlib does it these days, but raising 
Invalid('string') should work. If not, it probably would require fixing 
formlib or writing a lot of code to override existing components.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: z3c.form, applyChanges, IModifiedEvent

2007-08-13 Thread Stephan Richter
On Monday 13 August 2007 03:31, Philipp von Weitershausen wrote:
  By changing z3c.form.form.applyChanges to return a dictionary of
  interfaces and names of the attributes changed (instead of the current
  bool value) then I can easily create the correct additional attributes
  within the applyChanges method of EditForm:

 ...

 Sadly, zope.formlib doesn't send this info along either, therefore
 setting a bad example. I filed
 https://bugs.launchpad.net/zope3/+bug/98483 a while ago, just never got
 around to fix it... Thanks for reminding.

z3c.form now sets a good example, thanks to Darryl, whose proposal I 
implemented earlier today. ;-)

Reards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - how to raise/create an error in an action?

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 19:42 schrieb Stephan Richter:
 On Monday 13 August 2007 12:02, Hermann Himmelbauer wrote:
  I have a case where an error may occur in the form-action method
  (z3c.form, not formlib!), e.g. when data is not found in my database. I'd
  then like to output this error, similar when a widget error occurs.
  Moreover there are two simple cases:
 
  1) Errors that are related to a widget (hence the error should be shown
  along with the widget)
  2) Errors which are unrelated to the widget (like an Invariant).

 Hi Hermann,

 could you elaborate a little bit more? I think a step-by-step description
 of how *you* envision it to work would be great as well as a very specific
 use case of what you are trying to do.

Well, in my specific case, I have a search form for persons that queries (via 
zalchemy) a relational database and saves the result on the view object. Then 
I have a page template that displays this object.

My form also has an interface with some input fields, which are validated via 
the schema and I also have an invariant. In case there's an error, there is 
the error macro in the formui page template that displays these errors, which 
is fine. In my form there are three input fields after which can be searched:

1) A unique person ID (in case the user already knows it). This field has 
precedence.
2) A surename and name field (which may give multiple results)

Then I have a search button and a corresponding action. In this action, a 
DB-search is performed. There are two error cases:

1) The user enters an ID, which is invalid/unknown. In this 
case, invalid/unknown ID should be denoted for the widget and in the form 
status.
2) The user enters the name. In case there are no matching records, a not 
found error message should be displayed in the form status, which is not 
widget-related.

What I would favor is that the error-macros of the formui package can be 
reused, hence I need the same error objects in the view. Therefore I have to 
somehow set these errors. My first thought was to do it the following way 
(for the two cases):

1) Widget-specific error: Somehow set the error field, e.g. in the action:

self.widgets['myIDfield'].error=Invalid/unknown ID
Another variant would be to raise a specific error, like this:

raise WidgetActionError(['myIDfield', 'invalid/unknown ID'])

2) Generic error: Raise an exception, similar like in invariants:

raise Invalid(No data was found)

 My initial reaction is: This really needs to be supported by the API. Once
 I have more details, I will either implement an API for this or give you a
 response on how to do it in your code.

Great! Thanks a lot for your quick reply!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Invariants and forms

2007-08-13 Thread Maciej Wisniowski
 I've found two different examples(see below), but both don't display my given 
 exception message. The only thing i get is the standard error message.
What do you mean by standard error message?


 Second example
 (taken from:
 http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-invariants-in-interfaces-mit-zope-formlib-aktualisiert)
 
 import zope.interface
 
 class IUser(zope.interface.Interface):
 password = zope.schema.Password(title=uPasswort)
 password2 = zope.schema.Password(title=uWiederholung des Passworts)
 
 @zope.interface.invariant
 def arePasswordsEqual(user):
 if user.password != user.password2:
 raise zope.interface.Invalid(
 uDas Passwort und die Wiederholung sind nicht gleich.)

I think this should work.
Take a look at formlib/form.txt  - section about Invariants. If
it doesn't then I think your error is from somewhere else (again - what
is standard error message for you?)

There is also another possibility to do some checks between distinct
fields. To do this, in your action handler you may do your check
using values from 'data' dictionary, and if there is error you should
set:

self.form_reset = True
self.errors.append(u'your error message')


If you want to use this kind of validation (at action handler) to set
error messages for specific field you may do this either. I've added
function to my Form class for this:


from zope.app.form.interfaces import WidgetInputError
(...)
def setWidgetError(self, name, v):
 Helper function for validation purposes.
Sets error for widget
 @name - field name
 @v - error message

w = self.widgets.get(name)
if w:
w._error = WidgetInputError(
  self.context.__name__, w.label, v)
return w._error


In this case, if you validate your values in action handler you may do:


self.setWidgetError('password_confirmation',
u'Confirmation doesn\'t match')
self.form_reset = True


and error message will be bound to 'password_confirmation' field.


-- 
Maciej Wisniowski
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: zopeproject zcml problem

2007-08-13 Thread Philipp von Weitershausen

On 13 Aug 2007, at 15:18 , Andrew Rodriguez wrote:

Here is my configure.zcml:

configure xmlns=http://namespaces.zope.org/zope;
   xmlns:i18n=http://namespaces.zope.org/i18n 
   i18n_domain=library

  include file=permissions.zcml /
  include file=roles.zcml /




You seem to have gotten rid of all the include / statements that  
bootstrap ZCML and then load all the necessary components for your  
package. No wonder none of the ZCML directives work...


I suggest you create another project sandbox somewhere and copy the  
relevant lines from configure.zcml to your original one.


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users