Re: [Zope3-Users] Using formlib schema.Choice with zc.table FieldColumn
Whoa, really bad line breaks, here is the pastbin link http://zope3.pastebin.com/867518 David, zc.table makes rendering html tables more programmatic. --- [EMAIL PROTECTED] wrote: > Thanks for the direction, Gary. :) > > Getting a Choice field working in doctests was quite > a > challenge. It now fails as only as a zc.table > FieldColumn. I'm including the relevant doctests and > tests.py > > I apologize in advance for the verbose post. :) > > Kevin Smith > > > > > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.txt", > line 131, in fieldcolumn.txt > Failed example: > print formatter() > Exception raised: > Traceback (most recent call last): > File > "/root/temp/zc.table-0.6/eggs/zope.testing-3.0-py2.4.egg/zope/testing/doctest.py", > line 1348, in __run > compileflags, 1) in test.globs > File "", line 1, > in > ? > print formatter() > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 66, in __call__ > return '\n\n%s\n%s' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 75, in renderContents > return ' \n%s \n > \n%s \n' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 98, in renderRows > return ''.join([self.renderRow(item) for > item > in self.getItems()]) > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 106, in renderRow > return ' \n%s \n' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 110, in renderCells > return ''.join( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 114, in renderCell > return '\n %s\n\n' % > ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 121, in getCell > return column.renderCell(item, self) > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 162, in renderCell > return self.getRenderWidget( > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 114, in getRenderWidget > widget = self.getInputWidget(item, > formatter) > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 105, in getInputWidget > widget = component.getMultiAdapter((field, > request), iface) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 101, in getMultiAdapter > adapter = queryMultiAdapter(objects, > interface, name, context=context) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 114, in queryMultiAdapter > return > sitemanager.queryMultiAdapter(objects, > interface, name, default) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", > line 206, in queryMultiAdapter > return self.adapters.queryMultiAdapter( > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", > line 482, in queryMultiAdapter > result = factory(*objects) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 44, in ChoiceInputWidget > IInputWidget) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 101, in getMultiAdapter > adapter = queryMultiAdapter(objects, > interface, name, context=context) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 114, in queryMultiAdapter > return > sitemanager.queryMultiAdapter(objects, > interface, name, default) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", > line 206, in queryMultiAdapter > return self.adapters.queryMultiAdapter( > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", > line 482, in queryMultiAdapter > result = factory(*objects) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 315, in __init__ > super(ItemsEditWidgetBase, > self).__init__(field, vocabulary, request) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 83, in __init__ > assert field.context is not None > AssertionError > > > > > == fieldcolumn.txt == > > > >>> import re > >>> from zope import schema, interface > >>> class IContact(interface.Interface): > ... name = schema.TextLine(title=u'Name') > ... email = schema.TextLine( > ... title=u'Email Address', > ... > constraint=re.compile('[EMAIL PROTECTED]([.]\w+)+$').match) > ... salutation = schema.Choice( > ... title=u'Salutation', > ... values = ['Mr','Ms'], > ... ) > > >>> class Contact: > ... interface.implements(IContact) > ... def __init__(self, id, name, email, > salutation): >
Re: [Zope3-Users] Using formlib schema.Choice with zc.table FieldColumn
Thanks for the direction, Gary. :) Getting a Choice field working in doctests was quite a challenge. It now fails as only as a zc.table FieldColumn. I'm including the relevant doctests and tests.py I apologize in advance for the verbose post. :) Kevin Smith File "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.txt", line 131, in fieldcolumn.txt Failed example: print formatter() Exception raised: Traceback (most recent call last): File "/root/temp/zc.table-0.6/eggs/zope.testing-3.0-py2.4.egg/zope/testing/doctest.py", line 1348, in __run compileflags, 1) in test.globs File "", line 1, in ? print formatter() File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 66, in __call__ return '\n\n%s\n%s' % ( File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 75, in renderContents return ' \n%s \n \n%s \n' % ( File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 98, in renderRows return ''.join([self.renderRow(item) for item in self.getItems()]) File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 106, in renderRow return ' \n%s \n' % ( File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 110, in renderCells return ''.join( File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 114, in renderCell return '\n %s\n\n' % ( File "/root/temp/zc.table-0.6/src/zc/table/table.py", line 121, in getCell return column.renderCell(item, self) File "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", line 162, in renderCell return self.getRenderWidget( File "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", line 114, in getRenderWidget widget = self.getInputWidget(item, formatter) File "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", line 105, in getInputWidget widget = component.getMultiAdapter((field, request), iface) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", line 101, in getMultiAdapter adapter = queryMultiAdapter(objects, interface, name, context=context) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", line 114, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", line 206, in queryMultiAdapter return self.adapters.queryMultiAdapter( File "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", line 482, in queryMultiAdapter result = factory(*objects) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", line 44, in ChoiceInputWidget IInputWidget) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", line 101, in getMultiAdapter adapter = queryMultiAdapter(objects, interface, name, context=context) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", line 114, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", line 206, in queryMultiAdapter return self.adapters.queryMultiAdapter( File "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", line 482, in queryMultiAdapter result = factory(*objects) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", line 315, in __init__ super(ItemsEditWidgetBase, self).__init__(field, vocabulary, request) File "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", line 83, in __init__ assert field.context is not None AssertionError == fieldcolumn.txt == >>> import re >>> from zope import schema, interface >>> class IContact(interface.Interface): ... name = schema.TextLine(title=u'Name') ... email = schema.TextLine( ... title=u'Email Address', ... constraint=re.compile('[EMAIL PROTECTED]([.]\w+)+$').match) ... salutation = schema.Choice( ...title=u'Salutation', ...values = ['Mr','Ms'], ...) >>> class Contact: ... interface.implements(IContact) ... def __init__(self, id, name, email, salutation): ... self.id = id ... self.name = name ... self.email = email ... self.salutation = salutation >>> contacts = ( ... Contact('1', 'Bob Smith', '[EMAIL PROTECTED]', 'Mr'), ... Contact('2', 'Sally Baker', '[EMAIL PROTECTED]', 'Ms'), ... Contact('3', 'Jethro Tul', '[EMAIL PROTECTED]', 'Mr'), ... Contact('4', 'Joe Walsh', '[EMAIL PROTECTED]', 'Mr'), ... ) >>> from zope.formlib import form >>> class MyForm(form.EditForm):
[Zope3-Users] Using formlib schema.Choice with zc.table FieldColumn
Does anyone know if there is a trick in getting Choice schema's to work with zc.table FieldColumn or am I likely doing something wrong? Thanks, Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems reindexing on ObjectModifiedEvent
I need to investigate this further now, but this problem so far seems to isolated to the ValueIndex. Also, when the ObjectModifiedEvent is replaced with an ObjectCreatedEvent, the object is properly indexed. ... --- [EMAIL PROTECTED] wrote: > Hi list, > > For some reason, everytime an object is modified, > all > of the catalog information for that object is lost. > > A full catalog reindex works. > > Do I need to subscribe the interfaces of the catalog > indexes to the ObjectModfiedEvent or something? I > appreciate any pointers. > > > Thanks, > > Kevin Smith > > formlib code: > > @action(_("Apply"), condition=haveInputWidgets) > def handle_edit_action(self, action, data): > > if applyChanges(self.context, self.form_fields, > data, self.adapters): > > zope.event.notify(ObjectModifiedEvent(self.context)) > > > sample interface used in a setindex: > class ISection(interface.Interface): > """ """ > > section = schema.List(title=u"Section", > > value_type=schema.TextLine(title=u'Section'), > default=[], >required=False) > > > > ___ > Zope3-users mailing list > Zope3-users@zope.org > http://mail.zope.org/mailman/listinfo/zope3-users > ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Problems reindexing on ObjectModifiedEvent
Hi list, For some reason, everytime an object is modified, all of the catalog information for that object is lost. A full catalog reindex works. Do I need to subscribe the interfaces of the catalog indexes to the ObjectModfiedEvent or something? I appreciate any pointers. Thanks, Kevin Smith formlib code: @action(_("Apply"), condition=haveInputWidgets) def handle_edit_action(self, action, data): if applyChanges(self.context, self.form_fields, data, self.adapters): zope.event.notify(ObjectModifiedEvent(self.context)) sample interface used in a setindex: class ISection(interface.Interface): """ """ section = schema.List(title=u"Section", value_type=schema.TextLine(title=u'Section'), default=[], required=False) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Extent catalog question
Nice call. Registering as ICatalog (instead of IExtentCatalog) works perfectly. Thanks! Kevin Smith Gary Poster <[EMAIL PROTECTED]> wrote: On Jan 11, 2007, at 1:42 PM, [EMAIL PROTECTED]> wrote: > In my experience (zope2), large full textindexes require more and > more cpu time for every new object added to the point where it > takes several minutes for each new article uploaded! > > To avoid this problem, I was hoping to break the index into > smaller pieces by using extent catalogs to filter by year. Can > extent catalogs help mitigate a scaling issue like this? Sure. There might be considerations with sharing the lexicon or not, but I don't have any advice off the top of my head. > I've been able to instanciate one extent catalog per year, but it > doesn't automatically index content like a normal Catalog. It > requires a manual reindex. > And to automate indexing content, do I need to implement something > like these for an extent catalog? Neither of these match our experience. :-( I'm not sure what the difference is between our set up and yours. Did you register the extent catalog as an ICatalog? We do... Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Extent catalog question
In my experience (zope2), large full textindexes require more and more cpu time for every new object added to the point where it takes several minutes for each new article uploaded! To avoid this problem, I was hoping to break the index into smaller pieces by using extent catalogs to filter by year. Can extent catalogs help mitigate a scaling issue like this? I've been able to instanciate one extent catalog per year, but it doesn't automatically index content like a normal Catalog. It requires a manual reindex. And to automate indexing content, do I need to implement something like these for an extent catalog? Thanks in advance, Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zc.table FieldColumn question
Ok, so the following "works", but if someone with more knowledge could comment on this I'd appreciate it. class MovieColumnSubmit(fieldcolumn.SubmitColumn): def getId(self, item, formatter): return fieldcolumn.toSafe(item.__name__) def update(self, items, data, formatter): pass class MovieColumn(fieldcolumn.FieldColumn): def getId(self, item, formatter): return fieldcolumn.toSafe(item.__name__) def update(self, items, data, formatter): changed = False for item in items: id = self.getId(item, formatter) v = data.get(id, self) if v is not self and self.get(item, formatter) != v: self.set(item, v, formatter) changed = True if changed: self.setAnnotation('changed', changed, formatter) return changed class TableView(BrowserPage): """ Browser Page """ columns = ( MovieColumn( IMovieTime['brief']), MovieColumn( IMovieTime['times']), MovieColumnSubmit("apply", "MYFORM"), ) def __call__(self): items = [value for name, value in self.context.items()] formatter = table.Formatter( self.context, self.request, items, ('brief', 'times', 'MYFORM'), columns=self.columns, prefix="tableview") columns = self.columns for index, value in enumerate(columns): data = columns[index].input(items, formatter) columns[index].update(items, data, formatter) return """%s""" % formatter() ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] zc.table FieldColumn question
Does anyone have a simple example of how FieldColumn is used? I'm quite sure I'm missing a very serious step here, but have been unable to figure out how to "trigger" the update method. Any help at all would be appreciated. I've tried the following, the request values show on screen but fail to update the object. class MovieColumnSubmit(fieldcolumn.SubmitColumn): def getId(self, item, formatter): return fieldcolumn.toSafe(item.__name__) class MovieColumn(fieldcolumn.FieldColumn): def getId(self, item, formatter): return fieldcolumn.toSafe(item.__name__) class TableView(BrowserPage): columns = ( MovieColumn( IMovieTime['brief']), MovieColumn( IMovieTime['times']), MovieColumnSubmit("apply", "MYFORM"), ) def __call__(self): items = [value for name, value in self.context.items()] formatter = table.Formatter( self.context, self.request, items, ('brief', 'times', 'MYFORM'), columns=self.columns, prefix="tableview") return """%s""" % formatter() ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] adaptation/containers question
I'm trying to allow Zope3 Images in my IBlog container I've tried many variations of the follwoing without success. interfaces.py class IBloggable(Interface): """ Marker interface""" myclass.py class ImageBlogAdapter(object): implements(IBloggable) __name__ = __parent__ = None def __init__(self, context): self.context = context configure.zcml Thank you. Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Nested lists- "iteration over non-sequence"
Hi, Yes, one solution is custom widgets. Although I don't have a List of List example, I do have a List of Object example. It uses formlib, CustomWidgetFactory, ListSequenceWidget and ObjectWidget http://zope3demos.googlecode.com/svn/tags/zope3demos-200610-21/otherdemos/objectsofobjects2/ Project at http://zope3demos.googlecode.com/ Kevin Smith - Original Message From: Daniel M <[EMAIL PROTECTED]> To: zope3-users@zope.org Sent: Friday, October 20, 2006 2:47:36 PM Subject: [Zope3-Users] Nested lists- "iteration over non-sequence" Hello, I'm new to Zope, and using Zope 3.3. I have managed to get a simple site running. I am having trouble getting the web interface to let me edit an object that contains a list, where the type of values in the list, is an interface that also holds a list. I can’t get this “list inside a list” setup to work correctly. In my example, I have a Person object that contains a list of PersonInfo objects, where each PersonInfo contains a list of names. When I enter the view for Person (based on EditForm), it displays an edit form as I would expect. However, when I try to add a PersonInfo to the list via the interface, an exception is raised: “TypeError: iteration over non-sequence” (The full traceback is over 6 pages long, so I won’t post it, but it does mention “sequencewidget” many times). I've tried some variations to narrow down the problem: *If I change PersonInfo to hold just a string instead of a list, it works! *If I change Person to hold just a single PersonInfo instead of a list, it works! * Therefore, it seems like my Zope site is set up OK, but for some reason Lists of objects with Lists raise an exception. Am I missing something? Maybe I have to write some custom widget to get around this? Is this possibly a known problem? The code: ** People.py * class IPersonInfo(interface.Interface): names = schema.List( title=u"names", unique=False, value_type=schema.TextLine(title=u'name') ) class IPerson(interface.Interface): ID = schema.TextLine( title=u'ID', description=u'Persons ID code') the_list = schema.List( title=u"PersonInfo list", unique=False, value_type=schema.Object(IPersonInfo)) class PersonInfo(persistent.Persistent): interface.implements(IPersonInfo) def __init__(self): self.names = persistent.list.PersistentList() def PersonInfoWidget(context,obj,request): return ObjectWidget(context, request, PersonInfo) class Person(persistent.Persistent): interface.implements(IPerson) ID = "1-2-3" def __init__(self): self.the_list = persistent.list.PersistentList() class AutoEditView(form.EditForm): form_fields = form.Fields(IPerson) class PersonInfoView(form.EditForm): form_fields = form.Fields(IPersonInfo) ** end People.py * configure.zcml doesn’t do anything unusual, it sets up the views to use my custom widgets and sets up the edit views and security. Regards and thanks for your help! -- Daniel M [EMAIL PROTECTED] -- http://www.fastmail.fm - Send your email first class ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Field sets in zope3
At least part of this story is being worked on in z3c.multiform, however it's a project that states itself as being in it's infancy and doesn't seem to be very active. If anyone is interested in collaborating on this, I'm very interested in advancing this story. Kevin Smith Monterey County Weekly newspaper - Original Message From: David Pratt <[EMAIL PROTECTED]> To: zope3-users@zope.org Sent: Sunday, October 15, 2006 8:40:24 AM Subject: [Zope3-Users] Field sets in zope3 Hi. One thing I like about django's admin interface is the ability to easily group fields in a form with dozens of fields into field sets that expand or collapse a portion of the form making it more usable. Has anyone done anything similar using formlib at this point or have any pointers on accomplishing this functionality with least pain. Many thanks. Regards, David ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Problems in sequences of custom objects display view
I'm looking into formlib and display widgets. If anyone on the list has an example, I'd love to see it. The following Objects of List example works perfectly for edit view. For the display view it shows the AddressBook schema fine, but shows the Person schema edit form. I've googled all day, but have failed to come up with anything. Any help on this is appreciated. Thanks. Kevin Smith PS: Stephen, thanks for your feedback on mapDictToSchema browser.py person_widget = CustomWidgetFactory(ObjectWidget, Person) persons_widget = CustomWidgetFactory(ListSequenceWidget, subwidget=person_widget) class EditFormView(form.EditForm): form_fields = form.Fields(IAddressBook, render_context=True) form_fields['persons'].custom_widget = persons_widget class DisplayFormView(form.DisplayForm): form_fields = form.Fields(IAddressBook, for_display=True) form_fields['persons'].custom_widget = persons_widget app.py class IPerson( interface.Interface ): first = schema.TextLine( title=u"firstname" ) last = schema.TextLine( title=u"lastname" ) class Person( Persistent ): interface.implements( IPerson ) def __init__( self, first='', last='' ): self.first, self.last = first, last first= '' last= '' class IAddressBook( interface.Interface ): title = schema.TextLine( title=u'Title', required=False ) persons = schema.List( title=u'Persons', value_type=schema.Object( IPerson, title=u'person' ), required=False ) class AddressBook( Persistent ): interface.implements( IAddressBook ) def __init__( self, title="My Address Book" ): # create a default title self.title=title title = '' # don't forget to make lists persistent persons = PersistentList() ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] mapSchemasToDict
Perhaps this already exists somewhere, but I couldn't find it. Feed this function an object and it returns a dictionary of the associated schema key/value pairs including those that are PersistentList's of objects. Handy for view classes. Pointers and improvements welcome. Kevin Smith def mapSchemasToDict( context ): """ Map schemas to dict Provide data for demonstration:: >>> from zope import interface, schema >>> from persistent import Persistent >>> from persistent.list import PersistentList >>> class IPerson( interface.Interface ): ... first = schema.TextLine( title=u'First name' ) ... last = schema.TextLine( title=u'Last name' ) ... >>> class Person: ... interface.implements(IPerson) ... def __init__( self, first, last ): ... self.first = first ... self.last = last ... >>> p1 = Person( "Jim", "Fulton" ) >>> p1.first 'Jim' create addressbook content:: >>> class IAddressBook( interface.Interface ): ... title = schema.TextLine( title=u'Title' ) ... persons = schema.Object( IPerson, title=u'Persons') ... >>> class AddressBook(Persistent): ... interface.implements(IAddressBook) ... def __init__(self, title=''): ... self.title = title ... title = '' ... persons = PersistentList() ... >>> a1 = AddressBook( title="My Address Book" ) >>> a1.title 'My Address Book' >>> a1.persons.append( p1 ) >>> a1.persons.append( p1 ) >>> a1.persons [<...Person instance at ...>, <...Person instance at ...>] >>> d = mapSchemasToDict( a1 ) >>> d {'persons': [{'last': 'Fulton', 'first': 'Jim'}, {'last': 'Fulton', 'first': 'Jim'}], 'title': 'My Address Book'} """ listofinterfaces = list( interface.providedBy( context ) ) results = {} for oneinterface in listofinterfaces: fields = schema.getFieldNames( oneinterface ) if fields: for field in fields: fieldvalue = getattr( oneinterface( context ), field ) if isinstance( fieldvalue, PersistentList ): subfieldvalue = [] for subfield in fieldvalue: subfieldvalue.append( mapSchemasToDict( subfield ) ) fieldvalue = subfieldvalue results[field] = fieldvalue return results USAGE: class MyView( object ): ... @property def fields( self ): return mapSchemasToDict( self.context ) template.pt ... ...or as in the doctest example... returns... My Address Book ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Intended scope of viewlets?
I think the layer attribute may be missing. Kevin Smith - Original Message From: Alec Munro <[EMAIL PROTECTED]> To: Jürgen Kartnaller <[EMAIL PROTECTED]> Cc: zope3-users@zope.org Sent: Friday, October 6, 2006 11:39:23 AM Subject: Re: [Zope3-Users] Re: Intended scope of viewlets? I think I must be missing something about the way skins work now. I've created a master page that I can load when I don't specify a skin, but when I do specify a skin (++skin++MySkin), it is unable to find the page (404). Here's a rough approximation of my ZCML: There's lots more, and if any of it would be relevant, let me know, but this seems like it's the crucial part. I know it is finding the skin itself successfully, because the error message is not the standard Rotterdam one. The skin I'm using is currently just inherits from z3c.layer.minimal. I'll keep on trying things, but it's all kind of a shot in the dark right now. Thanks, Alec On 10/6/06, Alec Munro <[EMAIL PROTECTED]> wrote: > Hi Jürgen, > > So, just to give a concrete example for my case, I might replace this > (Metal-based): > > > > > > Nav tree needs a wee bit of work. > > > > > >Some Content > > > > > > with this (viewlet-based): > > > > > > Nav tree needs a wee bit of work. > > > > > > Some Content > > > > > > With seperate viewlet managers for "navigation" and "content", or any > other types of views I would expect to have on this page? Would a > "header" viewlet manager also be sensible, say if I wanted a title > that changed format depending on what type of content was being > viewed? > > Finally, are there any best practices for packaging in viewlet-based > templating? I'm currently creating this in my.project.browser.skin. > How about the viewlet manager names, should they be my.project.*, > my.project.browser.*, or something different? > > Probably some of these questions aren't relevant to the work you are > doing on viewlets, but I find it helpful to try to follow industry > practices as closely as possible, especially on something I don't have > much experience with, so I am easily able to follow tutorials, and > people who are helping me can more easily understand what I am trying > to do. > > Thanks very much for your help so far, I am excited about implementing > viewlets in our upcoming project. > > Alec > > On 10/5/06, Jürgen Kartnaller <[EMAIL PROTECTED]> wrote: > > Hi Alec. > > > > Alec Munro wrote: > > > Hi List, > > > > > > I'm just getting up to speed with viewlets, having read a thread here > > > and there in the past about them. I've installed the examples provided > > > on this list, and while I believe I understand how they work, I don't > > > understand in what circumstances they are most useful. The viewlets in > > > the examples are all very small, such as retrieving an formatting a > > > single piece of information about an object. However, from some of the > > > posts to this list, I get the impression they are also being used for > > > more complex items, like navigation menus. > > > > Menus are a perfect example for the use of viewlets. > > Have a look at z3c.menu. This package contains a base implementation for > > menus based on viewlets. > > > > > Is there a recommended scope? Can they be described in a way such as > > > "develop your templates up to point X, then use a viewlet for > > > development of further depth?". > > > > > > In my case, I am developing a new skin for a project, and my > > > experience with metal says to make the entire HTML page a macro with > > > slots for content and navigation. Is there a comparable viewlet-based > > > paradigm? > > > > Yes there is one, see below > > > > > > > > Also, am I correct in stating that when working with viewlets, the > > > only complete HTML page will be the primary skin file, with all > > > viewlets based on snippets of HTML? > > > > Thats exacly what we at Lovely Systems do and it works perfectly :) > > > > We have one base template which is used for all pages. Instead of > > defining slots to be filled by other templates it contains viewlet managers. > > We then provide different view classes to be able to register our > > viewlets for the pages of the application. > > The view classes are empty classes they are just providing the class > > name or if they provide additional functionality they also provide an > > interface. > > It is then possible to register the viewlets for specific pages. > > The most important thing on viewlets is that they are adapters on the > > *context*, the *request*, the *view* and the *manager*. > > > > The viewlet solution is an extremely productive way to implement a > > complex application. > > > > Make sure you read this : > > http://blogs.lovelysystems.com/srichter/2006/09/20/the-skin-browser-and-lovely-systems-new-development-workflow/ > > > > Stephan Richter describes here our use of the viewlet concept and our > > development workflow. The most importa
Re: [Zope3-Users] Intended scope of viewlets?
Hi Alec, Zope3demos has been updated with a stripped down example of Jürgen at Lovely Systems "no macro" masterpage design. You can get it from the trunk at svn checkout http://zope3demos.googlecode.com/svn/trunk/ zope3demos Should be good as of R35. FYI: There was a major refactoring of the package layout and url names. e.g. the index page is now reachable from http://localhost:8080/@@z3d.index.html Requires: z3c.viewtemplate, zope.viewlet, zope.contentprovider project page/bug collector: http://code.google.com/p/zope3demos/ Kevin Smith Monterey County Weekly newspaper Director of New Media - Original Message From: Alec Munro <[EMAIL PROTECTED]> To: "zope3-users@zope.org" Sent: Thursday, October 5, 2006 9:23:12 AM Subject: [Zope3-Users] Intended scope of viewlets? Hi List, I'm just getting up to speed with viewlets, having read a thread here and there in the past about them. I've installed the examples provided on this list, and while I believe I understand how they work, I don't understand in what circumstances they are most useful. The viewlets in the examples are all very small, such as retrieving an formatting a single piece of information about an object. However, from some of the posts to this list, I get the impression they are also being used for more complex items, like navigation menus. Is there a recommended scope? Can they be described in a way such as "develop your templates up to point X, then use a viewlet for development of further depth?". In my case, I am developing a new skin for a project, and my experience with metal says to make the entire HTML page a macro with slots for content and navigation. Is there a comparable viewlet-based paradigm? Also, am I correct in stating that when working with viewlets, the only complete HTML page will be the primary skin file, with all viewlets based on snippets of HTML? My questions are fairly broad-ranging, I know, but I have thus far been unable to find a straightforward explanation of viewlets, in terms of how they relate to general site development. Thanks, Alec ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] absolute_url in the viewlet ?
self.context.absolute_url looks very zope2ish, absolute_url is no longer inherited, it is an adapted component, so I believe the accepted Zope3 way is... from zope.app import zapi from zope.app.traversing.browser.interfaces import IAbsoluteURL . def render(self): url = zapi.getMultiAdapter( (self.context, self.request), IAbsoluteURL) return "IAbsoluteUrl == %s/" % url Kevin Smith - Original Message From: Christophe Combelles <[EMAIL PROTECTED]> To: zope3-users@zope.org Sent: Monday, October 2, 2006 7:14:22 PM Subject: [Zope3-Users] absolute_url in the viewlet ? Hi, How can I obtain the absolute_url of the context object in a content provider or in a viewlet ? For example, in the demo3 of zope3demos, the render() method of the viewlet returns self.context.__name__. ( http://zope3demos.googlecode.com/svn/trunk/demo3/demo.py ) How could I tell it to return the absolute_url instead of the __name__ ? (self.context.absolute_url gives a ForbiddenAttribute error.) thanks, Christophe ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] testbrowser passes but view fails
I have a situation where the functional test passes but when the page is actually viewed a ComponentLookupError is raised. This test passes using zope.testbrowser >>> browser.open('http://localhost/@@z3d.demo3.index.html') >>> 'ViewletDemo3' in browser.contents True A quick sanity check >>> browser.open('http://localhost/@@z3d.demo3.index.html') >>> 'does not exist' in browser.contents False When the actual page http://localhost/@@z3d.demo3.index.html is viewed, a ComponentLookupError is raised File "C:\Python24\Lib\site-packages\zope\contentprovider\tales.py", line 71, i n __call__ provider.update() File "c:\z3_inst\lib\python\zope3demos\viewletdemos\demo3\demo.py", line 26, i n update zope.viewlet.interfaces.IViewlet, name='MISSING'') File "C:\Python24\Lib\site-packages\zope\component\_api.py", line 103, in getM ultiAdapter raise ComponentLookupError(objects, interface, name) ComponentLookupError: ((, http://localhost:8080/@@z3d.demo3.index.html>, .browser.viewmeta.MasterpageView object at 0x033FA4B0>, object at 0x033FABB0>), , 'MISSING') MISSING does not exist. class DemoViewletManager(ViewletManagerBase): """ IDemoViewletManager marker interface """ zope.interface.implements(IDemoViewletManager) def update(self): rows=[] # list all in this directory for name, object in self.context.items(): # adapt each folder item to IViewlet rows.append( zope.component.getMultiAdapter( (object, self.request, self.__parent__, self), zope.viewlet.interfaces.IViewlet, name='MISSING') ) [entry.update() for entry in rows] self.viewlets = rows When MISSING is replaced with the correct name the functional tests pass and the view renders properly. I'm using Zope 3.3.0b2 on python 2.4.3 Am I missing something or is this a possible bug? Thanks. Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Viewlets for menus
Hi Florian, I put together some simple installable examples or zope.viewlet and zope.contentprovider. You can check them out from svn checkout http://zope3demos.googlecode.com/svn/trunk/ zope3demos project page http://code.google.com/p/zope3demos/ Kevin Smith - Original Message From: Florian Lindner <[EMAIL PROTECTED]> To: zope3-users@zope.org Sent: Thursday, September 21, 2006 4:47:33 AM Subject: [Zope3-Users] Viewlets for menus Hello, I've read various times that viewlets would be a good replacements for menu (or was it content providers?). How would such a replacement look like? Could anyone give a sketch of how to use viewlets? The concrete good I will probably be able to figure out myself, just the concept is not clear at the moment. Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Alternatives to macros
Stephan, I haven't quote got the hang of how to reuse viewlets, but I've setup an installable example at: 1) I took it you meant for SearchView to subclass BaseView instead of BrowserView 2) I added viewletManager directive in the zcml svn checkout http://zope3-viewlet-demo.googlecode.com/svn/trunk/ zope3demos project site: http://code.google.com/p/zope3-viewlet-demo Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Alternatives to macros
I'm investigating alternatives to macros, the following appears to work, but does anyone see anything particularly wrong or limiting with this implementation? Thanks, Kevin Smith app.py class PageView(BrowserView): content = pagetemplate.ViewPageTemplateFile('page.pt') def __call__(self): view = zope.component.getMultiAdapter( (self.context, self.request), name="masterpage.html") view.content = self.content return view() class NavbarContentProvider: implements(IContentProvider) adapts(Interface, IDefaultBrowserLayer, Interface) def __init__(self, context, request, view): self.context = context self.request = request self.__parent__ = view def update(self): pass def render(self): return 'Home' configure.zcml masterpage.pt master.pt master.pt master.pt footer page.pt page.pt ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] ANN: Viewlet examples
Hi Folks, Wow, viewlets are starting to look incredibly powerful. I'm posting my experimentation with them as a set of demos loosely based on the zope.viewlet readme. The first two demos are very simple and the third is a intermediate step towards the complex example in the readme. If you have any comments, suggestions or examples to contribute, please let me know. Project site: http://code.google.com/p/zope3-viewlet-demo/ svn checkout http://zope3-viewlet-demo.googlecode.com/svn/trunk/ zope3-viewlet-demo Tested only with: Zope 3.3.0b2 Possible Future Examples: * example of a navigation viewlet * using viewlets to "plugin" one app into another * Speck - a minimal admin framework Thanks, Kevin Smith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Replacing Macros with Contentprovider
Thanks for your reply. So, when you say macros still excel for general O-wrap, do you mean things like style_slot, script_slot and body_slot or do you also include things like header_slot, navigation_slot, breadcrumb_slot and footer_slot as well? I'm a little confused as to whether render() from contentprovider must only provide a string or if a zpt can be used? If a zpt can be used, does the namepace "view" access the contentprovider object or the __parent__ view object? Is the namespace "context" available as the original object? Ksmith --- Stephan Richter <[EMAIL PROTECTED]> wrote: > On Friday 08 September 2006 15:07, > [EMAIL PROTECTED] wrote: > > Is it possible to use contentproviders as an > > alternative to macros for providing the look and > feel > > of a site? I thought I saw someone mention > something > > to this affect. > > Yes. While we have not completely removed the use of > macros yet, we are pretty > close. There are some scenarios where macros still > accelerate, like the > general o-wrap, but other than that we have > completely replaced their need. > Viewlets/Content Providers are much more powerful > and since they are > representation components in their own right, it is > much easier to separate > template and logic. > > Regards, > Stephan > -- > Stephan Richter > CBU Physics & Chemistry (B.S.) / Tufts Physics > (Ph.D. student) > Web2k - Web Software Design, Development and > Training > ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Replacing Macros with Contentprovider
Is it possible to use contentproviders as an alternative to macros for providing the look and feel of a site? I thought I saw someone mention something to this affect. Thanks. ksmith ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] PayPal IPN for Zope3
I've started a project to integrate PayPal IPN with Zope3. A small portion of code is checked into the SVN to receive IPN notifications from PayPal, log a transaction and post a confirmation back to PayPal. More details at http://cherryslush.python-hosting.com/wiki/PayPalProject If you're interested in helping out, please drop me a line. Best regards, Kevin Smith ksmith93940-dev at yahoo ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users