[Grok-dev] Add Form URLS

Tim Cook timothywayne.cook at gmail.com
Sat Jan 24 12:35:44 EST 2009


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.

ehr.py
=============================================================
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (c) 2007, Timothy W. Cook and Contributors. All rights
reserved.
# Redistribution and use are governed by the license in
OSHIP-LICENSE.txt
#
# Use and/or redistribution of this file assumes you have read and
accepted the
# terms of the license.
##############################################################################

u"""
openEHR EHR Information Model package Rev. 5.1.0

"""


__author__  = 'Timothy Cook <timothywayne.cook at gmail.com>'
__docformat__ = 'plaintext'
__contributors__ = u'Renato Pesca <rpesca at gmail.com>'


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,
    )
    
    #contributions=List(
        #title=_(u"Contributions"),
        #description=_(u"List of contributions causing changes to this
EHR."),
	#value_type=Id,
        #required=True,
    #) At this point contributions are automatically contained in the
EHR and do not need to be a separae attribute. 
    
    
    #ehrAccess=Object(
        #schema=IObjectRef,
        #title=_(u"EHR Access"),
        #description=_(u"A reference to the EHR Access object."),
        #required=True,
    #) needs a better explaination
    
    ehrStatus=Dict(
        title=_(u"EHR Status"),
        description=_(u"A reference to the EHR Status object."),
        required=True,
    )
    
    #directory=Object(
        #schema=IObjectRef,
        #title=_(u"Directory"),
        #description=_(u"Optional directory structure."),
        #required=False,
    #) the directory structure is automatically setup in OSHIP
    
    #compositions=List(
        #title=_(u"Compositions"),
        #description=_(u"Master list of all compositions references."),
	#value_type=Object(schema=IObjectRef),
        #required=True,
    #) composition objects are automatically tracked in OSHIP
containers. 


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)
	

=======================================================






-- 
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
**************************************************************
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- 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/585e12b0/attachment.bin 


More information about the Grok-dev mailing list