[Grok-dev] REPOST Re: Add Form URLS

Tim Cook timothywayne.cook at gmail.com
Sat Jan 24 12:48:30 EST 2009


Sorry I should have deleted the commented out attributes for better
readability.  Here's the code again.

========================================================
import grok

from zope.interface import Interface, implements
from zope.schema import Datetime,URI,Id,Dict
from zope.i18nmessageid import MessageFactory

from app import Oship 

_ = MessageFactory('oship')

class IEhr(Interface):
    """
    Root EHR container Interface
    """
    
    systemId=URI(
        title=_(u"System Id"),
        description=_(u"Id of system where this EHR was created. This
should be the UUID from Python 2.6"),
        required=True,
    )
    
    ehrId=Id(
        title=_(u"EHR ID"),
        description=_(u"Id of this EHR."),
        required=True,
    )
    
    timeCreated=Datetime(
        title=_(u"Created"),
        description=_(u"Creation data/time"),
        required=True,
    )
    
    
    
    ehrStatus=Dict(
        title=_(u"EHR Status"),
        description=_(u"A reference to the EHR Status object."),
        required=True,
    )
    

class Ehr(grok.Container):
    """
    Root EHR container. 
    """
    
    implements(IEhr)
    
    def __init__(systemId,ehrId,timeCreated,ehrStatus):
        super(Ehr,self).__init__()
        
        self.systemId=systemId
        self.ehrId=ehrId
        self.timeCreated=timeCreated
        self.ehrStatus=ehrStatus
        
class AddEhr(grok.AddForm):
    grok.context(Ehr)
    form_fields = grok.AutoFields(Ehr)
    
    @grok.action('Add event')
    def add(self,**data):
        ehr001 = Ehr(**data)
        
class Edit(grok.EditForm):
    form_fields = grok.AutoFields(Ehr)   
    
class Index(grok.DisplayForm):
    grok.context(Ehr)
        
=======================================================


On Sat, 2009-01-24 at 15:35 -0200, Tim Cook wrote:
> There iss a wealth of highly technical and useful information on the
> Grok site and in the Grok and Zope source.
> 
> However, NO WHERE can I find how to add my objects to my Container.
> 
> I have an application in app.py called OSHIP and in app_templates the
> index.pt works great to display an intro page with various links.
> 
> I have another file called ehr.py (see source below) where I have used
> the examples from the site to try and use a schema to automatically
> create an add form.  But how to get from http://localhost:8080/oship to
> an addform so I can create an EHR totally escapes me.  I've also seen
> comments on the site regarding this issue.
> 
> Thanks for ny pointers.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090124/aa6b44bc/attachment.bin 


More information about the Grok-dev mailing list