[Grok-dev] How do I get current day as default in interface schema definition?

Kevin Teague kevin at bud.ca
Wed Feb 18 03:14:19 EST 2009


>
>
> http://grok.zope.org/doc/current/reference/directives.html#grok-adapts-declare-that-a-class-adapts-certain-objects
>
> When I try this technique and create a new object based on the  
> interface that specifies the schema, it does not work (the point of  
> this thread).
>
> Should that example be removed from the reference?

Yeah, that example isn't particulary helpful. It's got code which  
isn't used (such as the schema default) and it doesn't work  
(MammothSize needs to inherit from grok.Adapter). Perhaps a more  
simple example could be used ... but for now I've just removed the  
example. I also *attempted* to clarify the usage of grok.adapts() with:

In the case of a simple adapter which only requires a single object
for adapation, the :func:`grok.context` directive is used to declare
the interface or class the adapter is for. It is only necessary to use
:func:`grok.adapts` to declare the adapation requirements for a multi  
adapter.

But for a simple adapter, one can:

  - not declare the context when it's unambigous
  - declare the context when it is ambigous, or delcare it for the  
sake of declartion with grok.context()
  - use grok.adapts() instead of grok.context()

So maybe the text should be updated to reflect that, or is there a  
strong enough style conses that a particular method is used for  
registering simple adapters (e.g. using grok.context over grok.adapts)?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20090218/72ea5209/attachment.html 


More information about the Grok-dev mailing list