> Betreff: [Zope-dev] z3c.form: Need to register
> SimpleFieldValidator in localsite - how?
> I currently have the following simple validator:
> --------------- snip --------------
> class ActEmailValidator(SimpleFieldValidator):
> """Validates ACT E-Mail Addresses for customers"""
> def validate(self, value):
> super(ActEmailValidator, self).validate(value)
> if getattr(getSite(), 'bank_specifics', None) == u'act':
> if not re.match(r'^...@[0-9]+?.uebungsfirmen.at$', value):
> raise NotValidActEmail
> context = ICustomer,
> field = IFpFlat['email'])
> --------------- snip -----------------
> Normally, I simple did a "provideAdapter(ActEmailValidator)",
> which registered the above adapter in the global site registry.
> Unfortunately, this adapter should not be global, instead I
> need it site-specific. Therefore I tried the following, as I
> do with various
> sm = mySite.getSiteManager()
> This does not work and generates the following traceback:
> ------------ snip -------------
> line 416, in _dump
> PicklingError: Can't pickle <InterfaceClass
> z3c.form.util.IGeneratedForObject_43371984>: attribute lookup
> z3c.form.util.IGeneratedForObject_43371984 failed
> ------------- snip ------------
> >From this point I'm stuck - does somebody know what to do here?
> I yesterday thought z3c.baseregistry could help, but it seems
> that it would not, as I need this registration persistent and
> not during Zope startup only.
> It should be possible to add such sites during runtime,
> whereas their configuration (and registration of this
> adapter) has to be persistent.
> Any hints?
I guess this adapter is persistent (local) but not global
because during startup there is no site involved.
There is no way to have a local adapter involved for global schemas.
If there is no global validation druing startup, and you need a
local site validation then it's fine to use the baseregistry.
but take care you can't use the adapter during adding the site
itself. Then the adapter is only available if the site is added.
Not during adding.
> Best Regards,
> GPG key ID: 299893C7 (on keyservers)
> FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
> Zope-Dev maillist - Zope-Dev@zope.org
> ** No cross posts or HTML encoding! ** (Related lists -
> https://mail.zope.org/mailman/listinfo/zope )
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -