Re: [Zope3-Users] are aliases for content objects possible?

2005-08-25 Thread Stefan Rank

on 24.08.2005 16:32 Stéphane Brunet said the following:

Stefan Rank wrote:


The main idea is to give an object several aliases.
I would like to avoid having empty proxy-objects that fill the folder.
The object itself would know about its different names and a
presentation view could choose, e.g., the shortest one when used in a
list or as an html page title, and the others would be displayed below.

I am not sure if I quite understand what you want to do but... Creating 
custom views which changes the presentation would probably do the job, 
without need to create aliases. You can select the view you want by 
adding /@@name_of_view after the object in the url.




I don't think that would do it. The views would not provide two 
equivalent names for one object. And I actually do not want to have two 
different presentations, only two equivalent names.

From my first mail::

  'Equivalent' meaning you should be able to access it with
  scheme:host/path/name1 and scheme:host/path/name2 without any
  differences, and it should be in the catalog as only one object

A practical example: A text that describes a book.
I want to link to it as
 - http:/host/TheBookAboutLifeTheUniverseAndEverything
 - and http:/host/HinzKunzETAL2004

stefan

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] zope.schema.Object - Object of Objects

2005-08-25 Thread Christian Lueck
Hi!

I want to define add- and edit-views for objects of objects with
zope.schema.Object and zope.app.form.browser.ObjectWidget.  Roger
Ineichen and Andreas Reuleaux explained (on this list) howto write
custom widgets for objects.  I was trying to define a widget for objects
of objects (objects which's attributes are objects again), but didn't
get it for days.  Tonight I got it!  Since there is not yet a posting on
this problem on the list I decided to post it.  Maybe this is a
zope3-newbie problem, but maybe this list is the right place for these
kinds of problems.

Instead of using the subwidget directive I defined a kind of 'medium'
class which inherits zope.app.form.browser.ObjectWidget and in
which--again--ObjectWidgets are defined. I don't know if this is good
zope3 style but it works fine.  See file widget.py below...

Christian



file: interfaces.py


from zope.interface import Interface
from zope.schema import TextLine, Int, Object


class IPerson(Interface):

lastname = TextLine(
title=uLastname,
description=uPlease give the lastname.,
required=False)

firstname = TextLine(
title=uFirstname,
description=uPlease give the firstname.,
required=False)


class IPages(Interface):

start = Int(
title=uStart page,
description=uPlease give the start page.,
required=False)

end = Int(
title=uEnd page,
description=uPlease give the end page.,
required=False)


class IArticle(Interface):

author = Object(
schema=IPerson,
title=uAuthor,
description=uThe author of the article.,
required=False)

title = TextLine(
title=uArticle title,
description=uPlease give the title of the article.,
required=False)

pages = Object(
schema=IPages,
title=uPages,
description=uStart and end page of the article.,
required=False)


class INonsens(Interface):

article = Object(
schema=IArticle,
title=uArticle,
description=uA (nonsens) article,
required=False)


file: article.py


from zope.interface import implements
from objectsofobjects.interfaces import IPerson, IPages, IArticle, INonsens
from zope.schema.fieldproperty import FieldProperty


class Person:
The Person object.

implements(IPerson)


class Pages:
The Pages object.

implements(IPages)


class Article:
The article object.

implements(IArticle)


class Nonsens:
The nonsens object.

article = FieldProperty(INonsens['article'])

implements(INonsens)


file: widget.py


from zope.app.form.browser.editview import EditView
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import ObjectWidget, TextWidget
from zope.schema import TextLine

from objectsofobjects.interfaces import INonsens
from objectsofobjects.article import Person, Pages, Article


class Article_w(ObjectWidget):
This is the 'medium' class which inherits ObjectWidget
and in which ObjectWidgets are defined.

author_widget = CustomWidgetFactory(ObjectWidget, Person)
# (Note that you don't have do define a custom widget for the simple
TextLine 'title'!)
pages_widget = CustomWidgetFactory(ObjectWidget, Pages)


class NonsensEditView(EditView):
This is the customized EditView class.

__used_for__ = INonsens

#Give the 'medium' class Article_w as an argument to the contructor
of CustomWidgetFactory.  
article_widget = CustomWidgetFactory(Article_w, Article)



file: configure.zcml


configure
xmlns='http://namespaces.zope.org/zope'
xmlns:browser='http://namespaces.zope.org/browser'

  content class=.article.Person
require
permission=zope.View
interface=.interfaces.IPerson
/
require
permission=zope.ManageContent
set_schema=.interfaces.IPerson
/
  /content

  content class=.article.Pages
require
permission=zope.View
interface=.interfaces.IPages
/
require
permission=zope.ManageContent
set_schema=.interfaces.IPages
/
  /content

  content class=.article.Article
require
permission=zope.View
interface=.interfaces.IArticle
/
require
permission=zope.ManageContent
set_schema=.interfaces.IArticle
/
  /content

  content class=.article.Nonsens
require
permission=zope.View
interface=.interfaces.INonsens
/
require
permission=zope.ManageContent
set_schema=.interfaces.INonsens
/
  /content


  browser:editform
  label=Change nonsens article data
  name=edit.html
  schema=.interfaces.INonsens
  class=.widget.NonsensEditView
  menu=zmi_views
  title=Edit
  

Re: [Zope3-Users] zope.schema.Object - Object of Objects

2005-08-25 Thread Tom Dossis

Christian Lueck wrote:

 ... Since there is not yet a posting on
this problem on the list I decided to post it.  Maybe this is a
zope3-newbie problem, but maybe this list is the right place for these
kinds of problems.

I'm starting out on some new Zope3 work and would appreciate 'recipes' 
to look at.  Perhaps adding these to a site such as zopelabs.com would 
(also) be useful.  There is a Zope3 category there, but unfortunately 
only has zero items.

-Tom
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users