Re: RFC: schema by interface

"Martin Aspeli" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
On Thu, 13 Apr 2006 21:12:33 +0100, whit  
<whit-UE+B0n23d/[email protected]> wrote:

> Finally, insomnia gave me enough time to try this:
>
> http://svn.plone.org/svn/archetypes/Archetypes/branches/whitmo-schema-by-iface/
>
> there is one test failure and one error(not sure if these are related).  
>       Essentially, all calls to BaseObject.Schema now get passed to  
> ISchema(self).  The adapter takes care of fetching the schema object  
> from the instance and doing the aquisition wrapping.

Yay :)

Do you want to spell out the main benefits of doing this, for the record?


> here is one simpler alternative, registering a function as the schema  
> factory requires less code and is probably easier to understand::

Erm... I don't quite understand it :)

What's the point of doing this?

>  >>> from Acquisition import ImplicitAcquisitionWrapper as wrap
>  >>> def pschema_fetcher(inst):
> ...     return wrap(inst.schema)
>
> I'm curious to see if the following would work::
>
>  >>>from mytype import MyATSchema # some schema built at import time
>  >>>def module_schema_fetcher(inst):
> ...    return wrap(MyATSchema)
>
> The next obvious step is something like this::
>
>  >>> from archetypes.schema.interface import ILocalSchema
>  >>> from zope.component import getUtility
>  >>> def utility_schema_fetcher(inst):
> ...     util = getUtility(ILocalSchema, name="schema_locker")
> ...     schema=util.composeSchema(inst)
> ...     return wrap(schema)

Sorry, it's late, but can you explain what you're doing here?

Martin

-- 
(muted)



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.