[Zope3-Users] Schema fields vs custom metadata
Svenn Helge Grindhaug
Svenn.Helge.Grindhaug at bccs.uib.no
Fri Feb 23 12:33:30 EST 2007
On Friday 23 February 2007 15:59:59 Christophe Combelles wrote:
> The information about the course (I guess) is the main important
> information of your object, so it is not metadata. It would be better to
> store it as schema fields. Metadata is great to store additional
> information brought by an optional interface you put on object. Such as
> comments, rating, author, etc.
>
> The fact that the object is a container doesn't not prevent you from adding
> any attributes you want. It just means that ICourse is derived from (and
> extends) IContainer. You can also define a separate ICourseDetail with
> interesting fields, and implement both ICourse and ICourseDetail in your
> Course object.
This is what I thought as well, but I got stuck leading me to think I should
implement the information as meta data. I get a forbiddenAttribute error (see
below) after adding a course and trying to enter the newly created folder.
Could you please tell me what I missing here.
Many thanks!
Svenn.
<!-- Interface -->
class ICourse(IContainer):
"""Store information about the course and store participants"""
contains('cr.interfaces.IParticipant')
shortDesc = TextLine(
title = u'Short description',
description = u'Short description about the course.',
required = True
)
class IParticipant ... etc.
<!-- Implementation -->
class Course(BTreeContainer):
implements(ICourse)
shortDesc = u''
class CourseEditForm(EditForm):
form_fields = Fields(ICourse)
label = u'Edit course'
<!-- Configuration -->
<class class=".course.Course">
<implements
interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
permission="zope.View"
interface="zope.app.container.interfaces.IReadContainer"
/>
<require
permission="zope.View"
interface="zope.app.container.interfaces.IWriteContainer"
/>
</class>
<browser:page
for="cr.interfaces.ICourse"
name="edit.html"
class=".course.CourseEditForm"
permission="zope.ManageContent"
menu="zmi_views" title="Edit"
/>
<browser:addMenuItem
title="Add course"
class=".course.Course"
permission="zope.ManageContent"
/>
<browser:containerViews
for="cr.interfaces.ICourse"
contents="zope.ManageContent"
index="zope.View"
add="zope.ManageContent"
/>
<!-- Error message -->
2007-02-23T18:23:17 ERROR SiteError
http://127.0.0.1:8080/zope%20course/@@edit.html
Traceback (most recent call last):
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/publisher/publish.py",
line 133, in publish
result = publication.callObject(request, obj)
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/app/publication/zopepublication.py",
line 161, in callObject
return mapply(ob, request.getPositionalArguments(), request)
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/publisher/publish.py",
line 108, in mapply
return debug_call(obj, args)
- __traceback_info__: <security proxied
zope.app.publisher.browser.viewmeta.CourseEditForm instance at 0x9a530ec>
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/publisher/publish.py",
line 114, in debug_call
return obj(*args)
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/formlib/form.py",
line 751, in __call__
self.update()
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/formlib/form.py",
line 720, in update
self.setUpWidgets()
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/formlib/form.py",
line 783, in setUpWidgets
adapters=self.adapters, ignore_request=ignore_request
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/formlib/form.py",
line 385, in setUpEditWidgets
value = field.get(adapter)
File "/usr/local/src/Zope-3.3.0/build/lib.linux-i686-2.4/zope/schema/_bootstrapfields.py",
line 171, in get
return getattr(object, self.__name__)
ForbiddenAttribute: ('shortDesc', <cr.course.Course object at 0x9c0c2ac>)
127.0.0.1 - - [23/Feb/2007:18:23:17 +0200] "GET /zope%20course/@@edit.html
HTTP/1.1" 500 84 "http://127.0.0.1:8080/@@contents.html" "Mozilla/5.0 (X11;
U; Linux i686; en-US; rv:1.8.0.9) Gecko/20070209 Fedora/1.5.0.9-3.fc6
Firefox/1.5.0.9 pango-text"
More information about the Zope3-users
mailing list