[Zope3-Users] resource-directories

2008-12-02 Thread Frank Burkhardt
Hi everyone,

how can I get a list of all resourceDirectory's which are currently
accessible via my zope instance? I'm interested in a
name-physical_directory for all of them mapping.

Thank you,

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


[Zope3-Users] InvalidObjectReference error

2008-01-21 Thread Frank Burkhardt
Hi,

my zope 3 server contains a modified principal folder which is updated
on a regular basis via XMLRPC. This usually works fine but after some days, the
update process makes the zope server raise this error:

 InvalidObjectReference: Attempt to store a reference to an object from a 
separate connection to the same database or multidatabase

Restarting the server fixes the problem for some days.

I'm quite sure, this is some bug in my update code but I don't really know,
what I've to look for. Does anyone have an idea?

Regards,

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


Re: [Zope3-Users] Site Search (Text) Design Pattern Trouble

2007-10-27 Thread Frank Burkhardt
Hi,

On Fri, Oct 26, 2007 at 03:29:15PM -0400, Jeremy Roberts wrote:

[snip]

 I'm starting to suspect my design pattern here isn't going to support
 my requirements. Has anyone solved this problem or have any pattern
 advice?br

On my Site, I always try to obey the rule, that the default view of an object
found via a catalog search is what the user want's to see. For small objects
without a real view, I simply define a view which redirects to i.e. the 
parent's
default view.

Determining, which view, the ITidbit object is used in is very easy. Just make 
your
ISiteSection objects implement i.e. this interface:

class IGetTidbitView(Interface):
   def getTidbitViewName(tidbid):
  Returns the name of the view, the given object is used in.

Use the method in the browser redirect returned by the Tidbit's default view.

Regards,

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


Re: [Zope3-Users] How to get at the URL as entered in the browser?

2007-10-26 Thread Frank Burkhardt
Hi,

On Thu, Oct 25, 2007 at 08:51:41AM +0800, Yuan HOng wrote:
 On 10/24/07, Frank Burkhardt [EMAIL PROTECTED] wrote:
 
 
  The web server never gets the URL which as typed by the user. At least
  the protocol (http vs. https),  is lost. This is what you can do:
 
   url='http://' + request['HTTP_HOST'] + request['REQUEST_URI']
 
 
 Does this work for Zope3? I use zopeproject, and starting the server with

I don't know what zopeproject does but I use Zope3 (exclusively).

Regards,

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


Re: [Zope3-Users] How to get at the URL as entered in the browser?

2007-10-24 Thread Frank Burkhardt
Hi,

On Tue, Oct 23, 2007 at 11:08:35PM +0800, Yuan HOng wrote:
 Hi, list,
 
 Is it possible to retrieve the URL the user enters in the browser
 location box? The request's getURL method seems to return the
 traversed URL, including the default view name.
 
 In particular, I have a custom traverser for my object which extracts
 certain parameters from the URL path instead of the query string, like
 this:
 
 The url: http://myweb.com/myobject/param1/value1/param2/value2
 
 The traverser registered for myobject parses the remainder of the URL
 and then set the traversal stack to be empty.

The web server never gets the URL which as typed by the user. At least
the protocol (http vs. https),  is lost. This is what you can do:

 url='http://' + request['HTTP_HOST'] + request['REQUEST_URI']

Regards,

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


Re: [Zope3-Users] How to register multiple view for the same content class

2007-09-28 Thread Frank Burkhardt
Hi,

On Fri, Sep 28, 2007 at 05:33:56PM +0800, Yuan HOng wrote:
 On 9/28/07, Frank Burkhardt [EMAIL PROTECTED] wrote:
 
 
  You just need another browser:page here. Name it 'in-shelf-view' and
  use something like
 
   div tal:replace=structure book/@@in-shelf-view /
 
  to embed it.
 
 
 Thanks, that works. So all was missing is the '@@' notation to tell
 TALES to look up a view for Book.
 
  Registering the view for different shelves is possible, too. But this not
  a simple view anymore - it's a Multiview. You need an adapter for
  (book,shelve,request) to do that which means, a simple browser:page won't
  work and you'll be not able to use the object/@@view notation for that.
 
 
 If not object/@@view, what then? A custom traverse to lookup the
 Multiview maybe?

You could use a view as dispatcher which then would be traversed like 
object/@@view:

class MyDispatcher(object):
   def __call__(self):
  
realview=zapi.getMultiAdapter((self.context,self.context.__parent__,self.request))
  return realview()

class MyExampleView(object):
   def __init__(context,parent,request):
  self.context=context
  self.parent=parent
  self.request=request
   
   def __call__(self):
  return Book/shelf-specific html

*configure.zcml*
configure
   browser:page for=.interfaces.IMyBook name=view class=MyDispatcher ... 
/
   zope:adapter for=.interfaces.IMyBook .interfaces.IMyShelf IBrowserRequest 
... /
/configure

Regards,

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


Re: [Zope3-Users] How to register multiple view for the same content class

2007-09-28 Thread Frank Burkhardt
Hi,

On Fri, Sep 28, 2007 at 03:19:10PM +0800, Yuan HOng wrote:

[snip]

 Is it possible to register two different views for the Book, one for
 display in shelf, another for the detailed view? The one for the
 detailed view is simply a BrowerPage, but how to do the book-in-shelf
 view?

Exactly the same way.

 I'd like for my shelf template to look something like this:
 
 div tal:repeat=book shelf/books
   div tal:replace=structure book/in-shelf-view /
 /div
 
 Then I can maybe register different in-shelf-view's for different type
 of shelves.
 
 I tried registering a browser:view named 'in-shelf-view' for IBook. It
 doesn't work, because TALES doesn't know about the view.

You just need another browser:page here. Name it 'in-shelf-view' and
use something like

 div tal:replace=structure book/@@in-shelf-view /

to embed it.

Registering the view for different shelves is possible, too. But this not
a simple view anymore - it's a Multiview. You need an adapter for
(book,shelve,request) to do that which means, a simple browser:page won't
work and you'll be not able to use the object/@@view notation for that.

Regards,

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


Re: [Zope3-Users] Modified IntId utility

2007-09-25 Thread Frank Burkhardt
Hi,

On Mon, Sep 24, 2007 at 06:53:58PM +0200, Maken Seteva wrote:
 Fellow Zopers.
 I have made a slight modification to my intid util by inheriting from IntId 
 and overriding 
 _generateId().
 I do this to be sure that all new created objects will have an incrementing 
 number where
 the first object created gets id 1, the next gets id 2 and so on. This way I 
 get for free 
 sorting by
 oldest/newest.
 
 
 class MyIntIds(IntId):
  # We need a non-volatile nextid
  nextid = None
 
  def _generateId(self):
  # In the unlikely event that the nextid already
  # exists, we run this in a while loop to fix it.
  while True:
  if len(self) == 0:
  self.nextid = 1
  elif self.nextid is None:
  self.nextid = self.refs.maxKey() + 1
  uid = self.nextid
  self.nextid += 1
  if uid not in self.refs:
  return uid
  # Normally we would never get here..
  self.nextid = None
 
 
 What do you think about this? Is it safe to do this, or have i forgotten 
 any unforseen oddities
 that might occur in the future :O

I'm using a modified IntId utility which starts IDs at 1 and counts upwards, 
too.
I needed some permanent link for each object which was easy to implement via 
IntId.
The modification was made to safe keystrokes when typing the permalink. Typing
http://server/~251 is a lot easier than http://server/~344357462 :-) .

However, I don't use those IDs for anything else - like sorting.

Regards,

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


Re: [Zope3-Users] Rendering subobjects in pages

2007-08-06 Thread Frank Burkhardt
Hi,

On Mon, Aug 06, 2007 at 09:51:18AM -0230, Greg Baker wrote:
 How can I specify a template to render a sub-object within one of my content 
 objects?
 
 For example, pretend I have a Contact object which contains a Person object.  
 I am rendering the Contact object through a page template.
 
 class Contact:
 person = Person()
 
 In all the examples I see, rendering the person would be done using many tal 
 expressions like span tal:content=context/person/name / or something 
 similar.
 
 Is it possible to render the person object using a single tal expression, 
 div 
 tal:content=context/person /,

You may use a view which adapts Person() objects:

 div tal:content=structure context/person/@@defaultview /
 
You have to define e view for Person() like this:

*browser/configure.zcml*
[...]
   page
  for=..interfaces.IPerson
  name=defaultview
  template=mypersontemplate.pt
  [...]
   /
[...]

Don't forget to allow access to you Person()-class (e.g. via 
configure/class/allow).

[snip]

Regards,

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


Re: [Zope3-Users] Page Template not interpreted

2006-09-07 Thread Frank Burkhardt
On Wed, Sep 06, 2006 at 11:09:03PM +0200, Sébastien VINOT wrote:
 Hello,
 
 I'm working with Philipp Von Weitershausen's book and I get a strong result 
 concerning the Customizing a 
 site's layout (chapt. 8) : After setting up all the files my object receipt 
 displays a page which contains 
 (on the code) the metal tags.

[snip]

  title metal:fill-slot=title
tal:content=context/@@standard_macros/pageName/title

I dont think, the @@standard_macros view should be in a tal:content-attribut. 
Put the content
you want to be in this tag in this attribute:

 title metal:fill-slot=title tal:content=context/titleName/title

Regards,

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


Re: [Zope3-Users] Localizing Zope3 content

2006-07-07 Thread Frank Burkhardt
Hi,

On Fri, Jul 07, 2006 at 03:50:02PM +0200, Thierry Florac wrote:
 From now, I looked at Localizer and other Zope2 localization products
 which gave me a few ideas, but I'd really like to have as many advises
 as possible about this problem and the better way it should be handled
 in Zope3.

Did you think about your site's google-friendlyness? I'm using a similar
concept and i don't really know, how to provide search engines with
all the different language versions if the urls of different language
versions are equal.

Regards,

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


Re: [Zope3-Users] Re: Updating just a single object

2006-06-30 Thread Frank Burkhardt
Hi,

On Wed, Jun 28, 2006 at 07:38:03PM +0200, Philipp von Weitershausen wrote:

[snip]

 You can do this by explicitly rolling back the current transaction,
 modifying that single object and committing the transaction so that just
 those changes will be saved. Then you raise the exception and let Zope
 do its things (which, among others, include rolling back the now pretty
 much empty transaction).

Thank you, Phillip.

I wrote a short documentation on this:
 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/TransAction

Regards,

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


Re: [Zope3-Users] Dict Widget

2006-06-15 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 02:41:05PM -0500, mats.nordgren wrote:
 Frank,
 
 That would be great.  If you wish you can email it to me.
 
 This should be included in the trunk IMHO.
 
 Thanks,

I attached the widgets, zcml-statements to configure them and
modified Dict-implementation.

Good luck,

Frank
configure xmlns:zope=http://namespaces.zope.org/zope;
xmlns:i18n=http://namespaces.zope.org/i18n;
xmlns=http://namespaces.zope.org/browser; i18n_domain=mpgsite

!-- Dictionary widget dispatcher --
zope:view type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IInputWidget
for=zope.schema.interfaces.IDict
factory=mpgsite.browser.widgets.DictionaryWidgetFactory
permission=zope.Public /

!-- Choice()-keyed Dictionary Widget --
zope:view type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IInputWidget
for=zope.schema.interfaces.IDict 
zope.schema.interfaces.IChoice zope.schema.interfaces.IField
factory=mpgsite.browser.widgets.ChoicyDictionaryWidget
permission=zope.Public /

!-- Arbitrary Dictionary Widget --
zope:view type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IInputWidget
for=zope.schema.interfaces.IDict zope.schema.interfaces.IField 
zope.schema.interfaces.IField
factory=mpgsite.browser.widgets.SimpleDictionaryWidget
permission=zope.Public /
/configure
from zope.app.form.browser import ObjectWidget, ListSequenceWidget
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.interface import implements
from zope.app import zapi
from zope.app.form.browser.objectwidget import ObjectWidgetView, ObjectWidget
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from mpgsite.interfaces import IMpgSequenceField
from zope.app.form.browser.widget import BrowserWidget
from zope.app.form.interfaces import IDisplayWidget, IInputWidget
from zope.app.form import InputWidget
from zope.app.form.interfaces import WidgetInputError, MissingInputError
from zope.schema.interfaces import ValidationError, InvalidValue
from zope.app.i18n import MessageFactory
_=MessageFactory('mpgsite')
from zope.i18n import translate
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.app.form.browser.widget import renderElement
from zope.app.form.interfaces import ConversionError
from zope.app.form.browser import TextWidget, SequenceDisplayWidget
from zope.security.proxy import removeSecurityProxy
import sys
from zope.schema import Object
from zope.annotation.interfaces import IAnnotations

class MpgTextWidget(TextWidget):
def _toFieldValue(self, input):
try:
value = unicode(input)
except ValueError, v:
raise ConversionError(_(Invalid text data), v)
return value


class I18NTextLineWidget(MpgTextWidget):
   def __call__(self):
value = self._getFormValue()
if value is None or value == self.context.missing_value:
value = ''

kwargs = {'type': self.type,
  'name': self.name,
  'id': self.name,
  'value': value,
  'cssClass': self.cssClass,
  'style': self.style,
  'extra': self.extra}
if self.displayMaxWidth:
kwargs['maxlength'] = self.displayMaxWidth # TODO This is untested.

return renderElement(self.tag, **kwargs)

class SimpleObjectWidget(ObjectWidget):
A Widget that shows all widgets of an object
def __call__(self,context,request):
xhtml=''
for widget in context.subwidgets:
xhtml +=widget()
return xhtml


def ObjectInputWidgetDispatcher(context, request):
Dispatch widget for Object schema field to widget that is
registered for (IObject, schema, IBrowserRequest) where schema
is the schema of the object.
class Obj(object):
implements(context.schema)

widget=zapi.getMultiAdapter((context, Obj(), request), IInputWidget)
return widget

class ObjectInputWidget(ObjectWidget):
def getInputValue(self):
errors = []
content = self.factory()
for name in self.names:
try:
setattr(content, name, 
self.getSubWidget(name).getInputValue())
except Exception, e:
errors.append(e)
if self._error is None:
self._error = {}

if name not in self._error:
self._error[name] = e

   

Re: [Zope3-Users] Trusted adapters and annotated security

2006-06-15 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 01:24:14PM +0200, Frank Burkhardt wrote:
 Hi,
 
 Is there a general way make an adapter 'inherit' annotated security 
 permissions
 from the object it adapted?

I've found the solution. This statement

   adapter
   for=mpgsite.workflow.interfaces.IAnnotatable
   factory=.annotatableadapter.MyAdapter
   provides=.interfaces.IMyInterface
   trusted=true
   /

needs an additional attribute locate=true.

Regards,

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


[Zope3-Users] Trusted adapters and annotated security

2006-06-14 Thread Frank Burkhardt
Hi,

Is there a general way make an adapter 'inherit' annotated security permissions
from the object it adapted?

Some more information:

I've got an adapter IMyInterface-IAnnotatable. It's registered like this:

adapter
for=mpgsite.workflow.interfaces.IAnnotatable
factory=.annotatableadapter.MyAdapter
provides=.interfaces.IMyInterface
trusted=true
/
class class=.annotatableadapter.MyAdapter
require
permission=zope.ManageContent
interface=.interfaces.IMyInterface
/
/class

Usually no user has 'zope.ManageContent' permission on anything. I applied
annotated security permissions on a single content object to provide 'johndoe'
with zope.manageContent permission for just this single object:

 from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
 perms=IPrincipalPermissionManager(self.context)
 perms.grantPermissionToPrincipal('zope.ManageContent','johndoe')

'johndoe' is now able to i.e. call views like:

  page name=test.html
  for=.interfaces.IMyObject
  permission=zope.ManageContent
  /

on this object. The object has an addition view:

class MyView(BrowserView):
   def __call__(self):
  adapter=IMyInterface(self.context)
  adapter.method()

'method' is a method defined in IMyInterface but 'johndoe' is unable to 
successfully call MyView -
adapter.method() raises an Unauthorized exception.

Regards,

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


Re: [Zope3-Users] Dict Widget

2006-06-14 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 12:39:34PM -0500, mats.nordgren wrote:
 I'm totally clueless as how to get a dict widget to work.
 
 class IMyObject(Interface):
   mydict = Dict(
 title=u'My Dict',
 key_type=TextLine(),
 value_type=Int())
 
 I see in zope.app.form.browser the config file has no view defined for IDict
 and ?IField?.  Is it just a matter of configuring a view or do I also need to
 make a custom widget.

AFAIK there's no Dict widget in zope.

 Any help appreciated,

You could wait until tomorrow when I'm back @work. I wrote 3 widgets:
   * a generic dict widget (*:*)
   * a choice dict widget (IChoice:*) which will remove elements already
 used as keys from a given vocabulary.
   * a language dict widget (ILanguageChoice:*) which is for providing
 an arbitrary number of language versions of something.

Additionally I wrote a a fixed Dict-class. The zope one (zope.schema.Dict)
is broken and doesn't bind the key_type correctly.

Regards,

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


Re: [Zope3-Users] Assigning roles to principals

2006-06-14 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 09:35:47AM -0500, mats.nordgren wrote:
 Frank,
 
 Try this:
 
 role_map = IPrincipalRoleManager(context) == For example root of site.
 role_map.assignRoleToPrincipal(u'mpgsite.Authenticated', principal_id)

Thank you - It's working :-)

Regards,

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


Re: [Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?

2006-06-13 Thread Frank Burkhardt
Hi,

On Mon, Jun 12, 2006 at 01:19:26PM +0200, Lennart Regebro wrote:

[snip]

 We need a Zope3 FAQ where things like this can be put, because the

[snip]

There already is one (in german):

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/PlusPlus
 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/AtAt

Regards,

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


[Zope3-Users] Two object revisions and a simple workflow

2006-06-02 Thread Frank Burkhardt
Hi,

we are going to implement a simple workflow here. Example of our use case:

   * There are containers 'IArticleFolder' containing objects (e.g. IArticle)
   * Those objects sometimes contain subobjects (e.g. IImage, IFile)
   * When an object or one of it's subobjects is modified, it enters a simple 
workflow.
   * A modified object must not be visible to visitors. The lastest unmodified
 revision of the object should be displayed instead.
   * Two editors have to approve modifications of the object to finish the 
workflow and
 make the modifications visible to site visitors.

My main problem is: I have to use this mini-workflow for multiple application, 
not just
IArticleFolder/IArticle. I need some method that doesn't force me to rewrite 
all the
pagetemplates/views/... from scratch. Does anyone have an idea, how to do this?

Regards,

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


Re: [Zope3-Users] Problem with containment and @@absolut_url

2006-05-30 Thread Frank Burkhardt
Hi,

On Mon, May 29, 2006 at 08:26:38PM +0200, Achim Domma wrote:
 Hi,
 
 I have implemented ArticleFolder and Article like this:
 
 
 class Article(Persistent,Contained):
 implements(IArticle)
 title=u''
 body=u''
 
 class ArticleFolder(Folder):
 implements(IArticleFolder)
 
 
 Via ZMI I can add, edit and delete articles without problems. I use this TAL 
 statement in a view 
 for the object holding the article folder :
 
 p tal:repeat=article context/articles
 a
tal:content=article/title
tal:attributes=href article/@@absolute_urlasdf/a  
 /p
 
 This fails with an There isn't enough context to get URL information. 
 exception. When the 
 exception is thrown, I see in the debugger, that the context of AbsoluteUrl 
 is the id of the first 
 article as unicode string. And this string has of course no __parent__ 
 attribute!?
 
 I argued that context/articles might return ids, not objects, but in that 
 case article/title 
 should fail also. But if I remove tal:attributes, it works fine.

Remembering your last problem with Object()-schema, my guess is that you
stored your articles as a list ob Object()s in an articlefolder's
'articles'-attribute. This way a single article doesn't have an URL - it's
just an attribute - no matter which base classes (-Contained) you use.
You've got two options:

   1. A view on articlefolder that take some arguments and displays a given
  article.  You'd have to use something like this then:
   a ... tal:attributes=href 
${context/@@absolute_url}/articleview?${article/title} ... /
   2. Write your own traversal adapter that displays objects in lists like this:
   a ... tal:attributes=href 
${context/@@absolute_url}/++article++${article/title} ... /

If I were you, I'd take option one (if I guessed your problem right :-) ).

Regards,

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


[Zope3-Users] How to manually define an object's provided interfaces?

2006-05-29 Thread Frank Burkhardt
Hi,

I'm going to write an alternative implementation of
zope.app.file.interfaces.IFile . This implementation will automatically
determine the mime type of the data it's containing.

I would like to add a method that determines (guesses), if the current file
object contains an image...

 isimage=(mimetype(self.data).split('/')[0] == 'image')

... and I want to dynamically make the object implement another interface ...

 if isimage:
IImage.provide(self)
 else:
IImage.dontprovide(self)

Unfortunately, there is no 'provide' method on interfaces :-( .

Now the questions:

1. Is the list of a content object's provided interfaces stored persistently
   in the Zodb?
   
2. Is it according to Zope-, Python-, ... philosophy ok to danymically implement
   interfaces depending on the inner state of an object?
 
3. How do I manually make objects provide or unprovide given interfaces?

Regards,

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


Re: [Zope3-Users] Re: How to manually define an object's provided interfaces?

2006-05-29 Thread Frank Burkhardt
Hi,

On Mon, May 29, 2006 at 02:50:02PM +0200, j.kartnaller wrote:
 Have a look at zope.interface.__init__.py - alsoProvides

That's it - it's working :-) .

Thank you,

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


Re: [Zope3-Users] Create complex object

2006-05-25 Thread Frank Burkhardt
On Thu, May 25, 2006 at 02:45:04AM +0200, Achim Domma wrote:

[snip]

Just create another interface:

 class IWorkspace(Interface):
 title = TextLine(
title=uTitle,
description=uThe title,
default=uproCoders Workspace,
required=True)
 projects = Container(title=uProjects, description=uxxx)
 articles = Container(title=uArticles, description=uxxx)

can be written as:

 class IWorkspaceForAdding(Interface):
 title = TextLine(
title=uTitle,
description=uThe title,
default=uproCoders Workspace,
required=True)
 class IWorkspace(IWorkspaceForAdding):
 projects = Container(title=uProjects, description=uxxx)
 articles = Container(title=uArticles, description=uxxx)

and replace the schema IWorkspace by IWorkspaceForAdding in the addform.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-24 Thread Frank Burkhardt
Hi,

On Tue, May 23, 2006 at 11:21:54AM -0500, Jachin Rupe wrote:
 
 On May 23, 2006, at 5:33 AM, Frank Burkhardt wrote:
 
 [snip]
 
 
 content class=.entry.StreetAddress
 allow interface=.interfaces.IABookEntry /
 /content

[snip]

Try removing the content-statement for the Object()s.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-23 Thread Frank Burkhardt
Hi,

On Mon, May 22, 2006 at 09:59:09AM -0500, Jachin Rupe wrote:

[snip]

 I am getting a ForbiddenAttribute error.  I can run the addform with out 
 any errors but if I editform the street 
 field is blank (even though I added some text to it when I added it).  Then 
 if I makes some changes to the fields and 
 try to save my changes I get one of these:

[snip]

   content class=.entry.StreetAddress
   allow interface=.interfaces.IABookEntry /
   /content

[snip]

I bet '.interfaces.IABookEntry' doesn't cover the 'street' attribut. You should 
better use
'.interfaces.IStreetAddress' for your Object()-object.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-22 Thread Frank Burkhardt
Hi,

On Fri, May 19, 2006 at 02:21:23PM -0500, Jachin Rupe wrote:

[snip]

 I'm still getting a ComponentLookupError.  I'll just include the example 
 I'm trying to make work 
 at the bottom, it's pretty short.  I'm beginning to think there may be 
 something in your 
 explication that I need to understand.
 
 Also, from looking at your example I'm guessing your using the SVN version of 
 zope3, is that true 
 and do you happen to know if that would make a difference?  I'm currently 
 using Zope-3.2.1.

Yes, I'm using Zope-SVN but the ObjectWidget-Code was written for ZopeX3.
I can't see the Dispatcher-Widget. Are you sure, you implemented and registered 
it
as described in Part Vorarbeit(Preparation) of the Howto?

Regards,

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


Re: [Zope3-Users] Deleting subobjects works half only

2006-05-22 Thread Frank Burkhardt
Hi,

On Mon, May 22, 2006 at 11:43:46AM +0100, Chris Withers wrote:
 Stephan Richter wrote:
 for entry in tuple(tree.keys())

the tuple(...)-thing works.

 for entry in tree.iterkeys()

This doesn't work because the IContainer-interface doesn't cover it
so I don't have any permission - even as Manager. tree.__iter__()
seems to be the same but it complains about itself changing during
the delete loop.

 What, specifically, does iterkeys do? I've never bumped into it before and 
 I'm 
 interested if there's a contract that says iterkeys returns an immutable key 
 sequence, which is kindof implied above...

iterkeys returns an iterator not a sequence. However, it's easy to turn the
one into the other:

 [x for x in iterator()]

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Thu, May 18, 2006 at 12:34:06PM -0500, Jachin Rupe wrote:
 hi there
 
 I am having trouble getting form's generated for zope.schema.Object.  After 
 doing some more 
 reading it looks like I should be using formlib instead of 
 zope.app.form.browser.add.AddView and 
 zope.app.form.browser.editview.EditView

I'm currently writing a step-by-step-howto describing how to use the 
Object-schema and
how to write Widgets for it. It will be in german but all the code examples are
documented in english. URL is:

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

It's still work in progres but most of the work should be done within 6 hours.

Regards,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Thu, May 18, 2006 at 12:34:06PM -0500, Jachin Rupe wrote:
 hi there
 
 I am having trouble getting form's generated for zope.schema.Object.  After 
 doing some more 
 reading it looks like I should be using formlib instead of 
 zope.app.form.browser.add.AddView and 
 zope.app.form.browser.editview.EditView

I completed the schema.Object-howto:

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

Regards,

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


[Zope3-Users] Deleting subobjects works half only

2006-05-19 Thread Frank Burkhardt
Hi,

I've got a strange effect here. A view on an object of mine has to remove all
the objects childs:

class MyView(BrowserView):
   def __call__(self):
  for entry in self.context.keys():
 del self.context[entry]
  return ''

Unfortunately, the view removes just half the objects - independently of how 
much
objects are left inside the container.

The object itself looks like this:

class MyObject(BTreeContainer):
   implements(MyInterFace)

Is this a bug or some kind of protection against accidential removal? Is
there a more efficient way of removing all the BTreeContainer's objects at
once?

BTW: I've got the same effect on a different object, too.

Regards,

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


Re: [Zope3-Users] Deleting subobjects works half only

2006-05-19 Thread Frank Burkhardt
Hi,

On Fri, May 19, 2006 at 07:56:24AM -0400, Stephan Richter wrote:
 On Friday 19 May 2006 07:47, Frank Burkhardt wrote:
  Unfortunately, the view removes just half the objects - independently of
  how much objects are left inside the container.
 
 That is the correct behavior. BTrees change their internal data structure 
 with 
 every change, such as deletion of an item, and thus the keys() method is not 
 guaranteed to iterate over all items. Use one of the following instead:
 
 for entry in tuple(tree.keys())
 
 for entry in tree.iterkeys()

Thank you Stephan, you saved my day :-)

Best,

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


Re: [Zope3-Users] zope.schema.Object and custom widgets in formlib

2006-05-19 Thread Frank Burkhardt
Hi,

On Fri, May 19, 2006 at 11:37:51AM -0500, Jachin Rupe wrote:

[snip]

 I still haven't gotten it working yet though.  I'm going to keep trying to 
 figure out what 
 the problem is, I think I see what your basic strategy is.
 
 However there are a few error I found in your example you may be interested 
 in fixing:
 
 in your interfaces.py file you probably want the IPhoneBookEntry interface to 
 look like 
 this:

[...]

Sorry for the Typo - corrected it. But the whole concept works for me - I'm
using schema.Object, too.

Maybe I can help - what's the problem?

Regards,

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


Re: [Zope3-Users] Re: How to distribute distinct components among multiple Zope servers?

2006-05-17 Thread Frank Burkhardt
Hi,

On Wed, May 17, 2006 at 09:15:22AM +, Reinhold Strobl wrote:

[snip]

 Thanks for your reply, but I have looked on ZEO - however: this technology 
 only
 allows a seperation of application from the concrete storage. But what I am
 looking for is I want to seperate the application tier itself. For instance, I
 have got two utility components serving different functionality. But I want to
 distribute those components among two servers, but they should stay reachable
 from each other...

Why not using ZeO + two Zope servers in front of it that both provide all
the functionality? You can put a proxy server (don't forget to switch off
the cache) in front of them. This proxy server then examines all request's urls
and forwards them to the server resposible for the requested functionality.

Remember: It's always better to have two identical systems and use it
differently than to have two different systems.

Regards,

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


Re: [Zope3-Users] How to make catalog working?

2006-05-16 Thread Frank Burkhardt
Hi,

On Tue, May 16, 2006 at 07:08:34PM +0200, Florian Lindner wrote:
 Am Dienstag, 16. Mai 2006 12:02 schrieb Frank Burkhardt:

[snip]

  The IntID utility has to be registered *before* all the objects you
  want to find. No object created before you had a registered IntID
  will ever be found.
 
  Have a look at
 
   http://zope3.mpg.de/suchen (Das Prinzip)
 
 I've done that and it does not help.

Are you sure, your object implements the interface, you're indexing? Use the
introspector to find out.

Regards,

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


Re: [Zope3-Users] sequence of custom widgets

2006-05-12 Thread Frank Burkhardt
Hi,

On Fri, May 12, 2006 at 10:48:52AM +0200, Marco Mariani wrote:
 
 I've got a form which contains an object widget given by
 CustomWidgetFactory(ObjectWidget, MyClass)
 
 Now, how can I render a Sequence widget to store a list of MyClass
 instances?

some months ago, Phillip von Weitershausen wrote such a widget for me. I'm
not using it anymore and I don't know, if it's still working. But maybe it
will help:




configure.zcml
!--
A widget for rendering objects that are usually used
in lists of records structures.
--
zope:view type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IObject
provides=zope.app.form.interfaces.IInputWidget
factory=.widgets.ObjectInputWidget
permission=zope.Public /
!--
A template based widget for rendering edit forms out of 
sequences
(eg. Lists) that are a bit more user friendly than the defaults.
--
zope:view type=zope.publisher.interfaces.browser.IBrowserRequest
for=zope.schema.interfaces.IList 
zope.schema.interfaces.IObject
provides=zope.app.form.interfaces.IInputWidget
factory=.widgets.TemplateSequenceWidget
permission=zope.Public /
/configure.zcml





widgets.py
from zope.app.form.browser import ObjectWidget, ListSequenceWidget
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.interface import implements
from zope.app import zapi
from zope.app.form.browser.objectwidget import ObjectWidgetView
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.form.browser.widget import BrowserWidget
from zope.app.form.interfaces import IDisplayWidget, IInputWidget
from zope.app.form import InputWidget
from zope.app.form.interfaces import WidgetInputError, MissingInputError
from zope.schema.interfaces import ValidationError, InvalidValue
from zope.app.i18n import MessageFactory
_=MessageFactory('mpgsite')
from zope.i18n import translate
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.app.form.browser.textwidgets import TextWidget
from zope.app.form.browser.widget import renderElement

def ObjectInputWidget(context, request):
Dispatch widget for Object schema field to widget that is
registered for (Object, schema) where schema is the schema of the
object.
class Obj(object):
implements(context.schema)

return zapi.getMultiAdapter((context, Obj(), request), IInputWidget)

class TemplateObjectWidget(ObjectWidget):
A Widget that uses a page template
def __init__(self, context, request, factory, template_, **kw):
super(TemplateObjectWidget, self).__init__(context, request, 
factory, **kw)
class TemplateObjectWidgetView(ObjectWidgetView):
template = ViewPageTemplateFile(template_)
self.view = TemplateObjectWidgetView(self, request)

class TemplateSequenceWidget(ListSequenceWidget):
def __init__(self, context, field, request, 
template_='sequencewidget.pt', subwidget=None):
super(TemplateSequenceWidget, self).__init__(
context, field, request, subwidget)
class TemplateObjectWidgetView(ObjectWidgetView):
template = ViewPageTemplateFile(template_)
self.view = TemplateObjectWidgetView(self, request)

def __call__(self):
return self.view()
/widgets.py




sequencewidget.pt
div tal:define=sequence   context/_getRenderedValue;
 num_items  python:len(sequence);
 min_length context/context/min_length;
 max_length context/context/max_length
 i18n:domain=mpgsite
  tal:attributes=class context/classes

div class=itemstable
div class=items
  div tal:repeat=i python:range(num_items)
tal:block define=value  python:sequence[i];
   widget python:context._getWidget(i);
   nixpython:widget.setRenderedValue(value)
input class=editcheck type=checkbox
   tal:attributes=name string:${context/name}.remove_${i} /
tal:widget replace=structure widget /
/tal:block
  /div
  /div
  /div

  input type=submit value=Remove selected items
  tal:condition=python:sequence and num_items  
min_length
   tal:attributes=name string:${context/name}.remove
   i18n:domain=zope
   i18n:attributes=value remove-selected-items/

input type=submit value=Add item
   tal:attributes=name string:${context/name}.add
  tal:condition=python:max_length is None or num_items 
 max_length
   i18n:attributes=value
   i18n:domain=zope/

  input type=hidden
 

Re: [Zope3-Users] Indexing PDF files

2006-05-11 Thread Frank Burkhardt
Hi,

On Wed, May 10, 2006 at 03:29:34PM -0500, Sreeram Raghav wrote:

[snip]

 Initially the only files being indexed were ZPT pages, but after writing
 the adapter even text files were being indexed.
 However the problem is that when I try to add a PDF of Word documents, the
 files are not being indexed and showing an error that cannot decode files.

This adapter was just a demonstration on how to index a content object
containing a text field. It assumes that context.data contains just a plain
string. To index pdf files, you'll have to somehow convert the pdf data to
plain text:

from ModuleYouHaveToWrite import MagicPdfToText

class SearchableTextAdapter(object):
[...]
   def getSearchableText(self):
  text=MagicPdfToText(context.pdfdata)
  return (text,)

I don't know, if there's a pure python solution for extraction text from pdf 
files.
But you might consider calling an external program like 'pdftotxt' to do the 
job.
However, it's your adapters responsibility to act as define by the interface and
'ISearchableText' says, the adapter must provide plain indexable text.

Regards,

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


[Zope3-Users] PAU doesn't like Manager

2006-05-09 Thread Frank Burkhardt
Hi,

I'm currently trying to use PAU. It seems to work fine but when I try to login
as 'manager' as defined via ZCML, it doesn't work.

Now I'm going to write a second plugin which will check the credentials of the
manager. It will return a PrincipalInfo with id=pau.manager .

Michael Howitz suggested to use something like

 principalPermissionManager.grantAllPermissionsToPrincipal(pau.manager)

to raise the power of a principal. Unfortunately my IAuthenticator plugin
never sees a IPrincipal object but IPrincipalInfo only.

Where do I have to call grantAllPermissions... to make an arbitrary
principal manager-like?

Where does Zope store those grants? In the PrincipalAnnotation Utility?

Is there another way to re-enable the manager when a PAU is registered?

Thank you for any hints.

Regards,

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


Re: [Zope3-Users] Searching and Indexing in Zope3

2006-05-09 Thread Frank Burkhardt
Hi,

On Tue, May 09, 2006 at 10:32:45AM -0500, Sreeram Raghav wrote:
 Hi Frank,
 Thanks for the Zope3 Indexing and Searching HOWTO
 I translated your page to english and was trying to work it out.
 Here's exactly what i did:
 
 1. Logged into zope3 manager
 2. went to ++etc++site/default/ and created an unnamed *initId* utility
 over there.
 3. added a catalog named 'catalog1' with interface *
 zope.app.catalog.interfaces.ICatalog*http://192.168.60.225/++apidoc++/Interface/zope.app.catalog.interfaces.ICatalog/index.html
 and set access to Public
 3. went inside catalog1 and added a TextIndex with an interface 
 zope.index.text.interfaces.ISearchableText with Field Name as
 searchableText.
 4. then went into catalog1 and clicked on advanced and it was showing
 TextIndex with document count - 0 and word count - 0.
 It means that the objects are not being indexed, can you suggest what the
 problem could be.
 Than you

1. You have to check the Callable checkbox to tell the index that 
searchableText is
   a method and not just an attribute.

2. Selecting an interface means telling the index Add (only!) objects of this 
type
   (=implementing this interface) to the index. This is not 100% correct - the 
index
   will add objects which can be adapted to the search interface, too.
   - If you have objects that don't implement ISearchableText, you won't get 
them indexed
  without writing an adapter like this (untested!):
  
adapter.py:

 from zope.index.text.interfaces import ISearchableText
 from zope.component import adapts
 from zope.interface import implements
 
 MyObjectToSearchable(object)
implements(ISearchableText)
adapts(IMyObject)

def __init__(self,context):
   self.context=context

def searchableText(self):
   return self.context.data

configure.zcml:
   adapter
  factory=.adapter.MyObjectToSearchable
   /

Sorry, I'll add this adapter stuff to the howto asap :-) .

Regards,

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


Re: [Zope3-Users] Integrating text indexing engine into Zope 3

2006-04-28 Thread Frank Burkhardt
Hi,

On Fri, Apr 28, 2006 at 02:29:51PM +0200, Achim Domma wrote:
 Hi,
 
 I want to integrate support for a specialized text indexing engine into Zope 
 3. The engine is able 
 to provide documents which are similar to a reference document.

I'm curious: How are you going to do this (comparing documents, determining 
similiarity)?

 First I had a look at ICatalog, but IInjection seems to be the way to go. 
 Could somebody give me a 
 high level overview on how to use / implement these interfaces?
 
 I currently think about the following steps:
 
 - Implement the index as local utility.
 - Define an interface IMyStorageDocument for documents to be stored in my 
 index.
 - Capture somehow if objects are created or deleted. Check if the object can 
 be adapted to 
 IMyStorageDocument. If yes, store it in the index or remove it.

You should have a look at zope.app.catalog.interfaces.IAttributeIndex which
seems to be what you want. Write your own implementation of an index
implementing IAttributeIndex. Your index will later be created as a child of
an ICatalog object which will take care of created, modified or deleted
content objects on your server and tell all its indices (-subobjects) about
those changes.

 Clients then only have to implement an adapter for documents which should
 be indexed. To search for documents one could access the index as local
 utility.

This is basically what I did: I wrote an interface providing 3 methods that are
used by my index: getTitle(), getContent(), getAbstract().

hth

Regards,

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


Re: [Zope3-Users] newbie question on i18n

2006-04-26 Thread Frank Burkhardt
Hi,

On Wed, Apr 26, 2006 at 11:14:19AM +0200, Riccardo Tonon wrote:
 Hi everybody,
 
 I'm developing a multilanguage site in Zope 3.
 
 I've just prepared it to support the i18n based on the browser language.
 
 I would like also to let the user decide which language to use. (e.g. using a 
 combo 
 box present on each page of the site)
 
 Anybody has an example where I could learn from?

I'm developing a multilingual site, too. It works like this:
   * browser language preferences are usually used to determine favorite 
language
   * users can click on one of 3 small flags to override browser preferences
 with a different language
   * all data fields on content objects are stored as dictionaries like this:
 context.sampledata={'de':'Einige Daten','en':'Some Data'}
   * Data fields are inserted into pagetemplates using a special metal-namespace
 div tal:content=context/sampledate/mpgi18n:text /
   * The displayed language version is negotiated which means that the
 original browser language preference list is really treated as a
 list.

I attached the necessary BrowserLanguage-adapter, zcml (look for the
zope:adapter-statement) and the BrowserView which is used to define the
override language.

Disadvantage of my solution:
   * It's using (session)cookies

hth.

Frank
?xml version=1.0 encoding=iso-8859-1?
configure
xmlns=http://namespaces.zope.org/browser;
xmlns:zope=http://namespaces.zope.org/zope;
xmlns:i18n=http://namespaces.zope.org/i18n;
i18n_domain=mpgsite


!-- I18N Widget --
zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IInputWidget
for=mpgsite.i18n.interfaces.II18N
factory=mpgsite.i18n.browser.widgets.SimpleI18NInputWidget
permission=zope.Public
/

zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IDisplayWidget
for=mpgsite.i18n.interfaces.II18N
factory=mpgsite.i18n.browser.widgets.I18NDisplayWidget
permission=zope.Public
/
zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IDisplayWidget
for=mpgsite.i18n.interfaces.II18N 
zope.schema.interfaces.ITextLine
factory=mpgsite.i18n.browser.widgets.I18NTextDisplayWidget
permission=zope.Public
/
zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IDisplayWidget
for=mpgsite.i18n.interfaces.II18N 
zope.schema.interfaces.IBytesLine
factory=mpgsite.i18n.browser.widgets.I18NTextDisplayWidget
permission=zope.Public
/
zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IDisplayWidget
for=mpgsite.i18n.interfaces.II18N 
zope.schema.interfaces.ISourceText
factory=mpgsite.i18n.browser.widgets.I18NTextDisplayWidget
permission=zope.Public
/
zope:view
type=zope.publisher.interfaces.browser.IBrowserRequest
provides=zope.app.form.interfaces.IDisplayWidget
for=mpgsite.i18n.interfaces.II18N 
zope.schema.interfaces.IField
factory=mpgsite.i18n.browser.widgets.I18NSimpleDisplayWidget
permission=zope.Public
/

addform
name=add_I18NConfig.html
schema=mpgsite.i18n.interfaces.II18NConfig
content_factory=mpgsite.i18n.app.I18NConfig
permission=zope.ManageContent
label=Add I18N-configuration utility

widget field=i18nsortorder 
class=zope.app.form.browser.BytesWidget
required=False convert_missing_value=False 
/
/addform
addMenuItem
class=mpgsite.i18n.app.I18NConfig
title=I18N Config
description=A configuration utility for I18N content
permission=zope.ManageContent
view=add_I18NConfig.html
/

editform
schema=mpgsite.i18n.interfaces.II18NConfig
name=edit.html
permission=zope.ManageContent
i18n:domain=zope
menu=zmi_views
title=Edit
label=Edit
/
defaultView

Re: [Zope3-Users] Security Question

2006-04-23 Thread Frank Burkhardt
Hi,

On Sat, Apr 22, 2006 at 05:06:15PM -0500, Jachin Rupe wrote:
 hi there
 
 Is there a good example out there of setting up security based on some
 sort of ownership system?
 
 I'm working my way though the Zope book.  What I would like to be able to
 do is allow the User who created a message to edit only their messages
 (the messages they created).  I think I've read all the relevant chapters
 of the Zope book and I can't find a place where it explains that.  Did I
 miss is somewhere?

I'm going to implement object ownership, too. My idea is to assign a role
membership to the user (e.g. 'mysite.Owner') using annotated
per-object-security information (see
zope.app.securitypolicy.interfaces.IPrincipalRoleManager).

I might need a special permission ('mysite.OwnerAccess') which is
ZCML-granted to the 'mysite.Owner' role and used in all the views
I want' to be owner-only.

The role will be assigned on object creation - I'm not sure, if I can use
an event to do so because the request object will be needed to know the
creating principal. In any case it should be possible to assign the role
in the content object's __init__() method.

hth

Regards,

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


Re: [Zope3-Users] Re: Referencing objects in auto-generated forms

2006-04-18 Thread Frank Burkhardt
Hi,.

On Sun, Apr 16, 2006 at 01:48:37PM -0500, Jeff Rush wrote:

[snip]

 Frank, I thought vocabularies were being de-emphasized though, in favor of 
 the newer 'sources' component?  
 Vocabularies were good for short lists of choices, but because it read them 
 all into memory at once not so good 
 at lazy evaluation.  Sources supposedly uses an iterator and is good for both 
 short and long lists, as I roughly 
 understand it.

Hmm - I've heard about Sources before but I didn't know the difference to
vocabularies. Thank you for the hint.

BTW: Does de-emphasized mean deprecated and no longer supported in 
Zope3.nnn ?

Regards,

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


[Zope3-Users] Sending data to widgets

2006-04-18 Thread Frank Burkhardt
Hi,

I need to send some data from a view class to all widgets that are
used in the form. Unfortunately some of the widget that need to receive those
data are contained e.g. in lists or dictionaries.

I tried to do somthing like this:

 request._data=somedata

My view class would add 'somedata' to the request and all the widget would be 
able
to use it.

But the the BrowserRequest doesn't like to be modified. It there a chance to
transport data throught the request object without modifying the depth
of the zope core?

Maybe there's a way for widgets to access the view class directly?

Regards,

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


Re: [Zope3-Users] Re: Sending data to widgets

2006-04-18 Thread Frank Burkhardt
Hi,

On Tue, Apr 18, 2006 at 03:20:49PM +0200, Philipp von Weitershausen wrote:

[snip]

 Right. Requests are read-only to the application.
 
  It there a chance to transport data throught the request object
  without modifying the depth of the zope core?
  
  Maybe there's a way for widgets to access the view class directly?
 
 A typical solution is to push data to the widgets. IWidget (from
 zope.app.form.interfaces) defines a 'setRenderedValue' method for
 widgets that can be used to do that.
 
 If you are using zope.formlib, you can also implement a custom
 setUpWidgets method (documented in IFormBaseCustomization from
 zope.formlib.interfaces). The default one for edit forms looks like this:
 
 def setUpWidgets(self, ignore_request=False):
 self.adapters = {}
 self.widgets = setUpEditWidgets(
 self.form_fields, self.prefix, self.context, self.request,
 adapters=self.adapters, ignore_request=ignore_request
 )
 
 setUpEditWidgets (defined in zope.formlib.form) will take the widget's
 default values from self.context. For example, you could pass in
 something other than that (perhaps an object holding the data you want
 the widgets to present). You just have to make sure that it also
 provides the interface that you're generating the form from.

My problem is not about data the widget should display but about data
that controls the widget's behaviour.

In this case my form consists of some widgets representing a schema interface
plus a special I18NController widget which is e.g. used to define, in which
order different language versions of the form's fields should be displayed.
(-This is about I18Nd content, stored in dictionary-fields)

Problem is: Some of the Widgets that should receive data from the 
I18NController
are not known to the formlib because they are multiadapter-queried inside e.g.
a ListInputWidget. The request + the context seem to be the only objects 
accessible
to all the widgets - but I don't want to store language order information in 
zodb which
leaves the request object only.

Is there really no chance to store information as attributes of the request?

Regards,

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


[Zope3-Users] Object modified or not

2006-04-18 Thread Frank Burkhardt
Hi,

how does Zope decide, if a persistent object is modified?

What I'm interested in:

Does
 
   myobject._foo='bar'
   delattr(myobject,'_foo')
 
make Zope create a new version of the 'myobject' in zodb?

Regards,

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


Re: [Zope3-Users] Beyond ICatalog.searchResults

2006-04-13 Thread Frank Burkhardt
Hi,

On Thu, Apr 13, 2006 at 04:27:15PM +0330, Mohsen Moeeni wrote:
 Hi;
 
 Looking at ICatalog interface, I could not figure out
 how can I request some simple and common operations
 from my catalog.

You don't really have to cope with the catalog but with your indexes only.
The catalog's job is just to subscribe to object
creation/modification/remove events and to send your search request
to the index you want to use. Everything else depends on the indexes.


 - Sorting on a field index.

What do you mean by sorting? A index is a set of (word - contentobject)
mappings. It doesn't make sense to sort it.


 - Returning the first N-th results (Hopefully without
   awakening all catalog records - if that makes any sense)

Depends on the index only. i.e.: I modified Ting3 (a wrapper for
making TextIndexNG3 Zope3-ready) to accept not just unicode queries
but dictionaries, too. This way I'm able to do things like this:

 querydict={'query':what i wanna %find,'similarity_ratio':0.2,'language':'en'}
 catalog.searchResults(ting3=querydict)

The Dictionary is passed to the 'ting3' index without any further checks.

You'll need to modify the index' apply-method to accept more than just
plain text queries and possibly more of the index to make it returning
just the first N-th results or other fancy stuff.


 - Defining an index which indexes an objects interfaces
i.e the output of interface.implemntedBy(ob)

Should be possible to use a slightly modified text index to do this.

Regards,

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


Re: [Zope3-Users] understanding security

2006-04-07 Thread Frank Burkhardt
Hi,

On Fri, Apr 07, 2006 at 03:33:28PM +0200, Achim Domma wrote:
 Hi,
 
 I'm just learning Zope and have a question regarding the security model:
 
 Do I understand it right, that I do not grant a permission to a principal on 
 a certain 
 object instance? I only grant a permission to use a certain interface!?

You can either grant permissions to principals (or groups/roles) globally. 
Those permissions
can be used in multiple ways:
   * To protect Views. You can only access views you have permissions for (e.g. 
browser:page ... )
   * To protect attributes/methods of classes (*not objects*) (class 
...required interface=...)
   * To define, who is allowed to modify certain attributes (class 
...required set_schema=... )

Additionally you may grant permissions (and role memberships) on a per object 
(*not per class*)
basis ( using e.g. the grant.html-View) which effects only a single object.

Regards,

Frank

PS: @zope-gurus: Please correct me if I'm wrong, I' still learning, too :-)
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Adapting multiple times

2006-04-05 Thread Frank Burkhardt
Hi,

I've got objects implementing interface

 IMyObject
 
and two adapters:

 IMyObject - ISearchable
 ISearchable - ISearchableEN

I would like to use a TextIndex to do fulltext search on objects
implementing ISearchableEN .
Unfortunately this doesn't work. The TextIndex tries something
like this to adapt an object to the given interface:

 ISearchableEN(myobject)

Which fails (Unable to adapt) because there is no adapter
IMyObject - ISearchableEN and Zope doesn't try to adapt multiple
times ( IMyObject - ISearchable - ISearchableEN ).

Does anyone have an Idea how to do this or do I have to modify
the TextIndex?

Regards,

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


Re: [Zope3-Users] Adapting multiple times

2006-04-05 Thread Frank Burkhardt
Hi,

On Wed, Apr 05, 2006 at 08:59:19AM +0200, Michael Howitz wrote:
 Am Mittwoch, den 05.04.2006, 08:48 +0200 schrieb Frank Burkhardt:
  Hi,
  
  I've got objects implementing interface
  
   IMyObject
   
  and two adapters:
  
   IMyObject - ISearchable
   ISearchable - ISearchableEN
  
  I would like to use a TextIndex to do fulltext search on objects
  implementing ISearchableEN .
  Unfortunately this doesn't work. The TextIndex tries something
  like this to adapt an object to the given interface:
  
   ISearchableEN(myobject)
  
  Which fails (Unable to adapt) because there is no adapter
  IMyObject - ISearchableEN and Zope doesn't try to adapt multiple
  times ( IMyObject - ISearchable - ISearchableEN ).
  
  Does anyone have an Idea how to do this or do I have to modify
  the TextIndex?
 
 Idea: Write an adater which Adapts IMyObject to ISearchableEN. This
 Adapter can be a function which only does the adaption chain and returns
 the Adapter to ISearchableEn adapter.

Thank you for the quick response. Problem ist: there is not just ISearchableEN
but one interface like that per supported language (~ 10 languages supported).
I expect to write at least 20 content object types. It just doesn't scale.

Doing the adaption chain manually in a modified TextIndex is the only
alternative, if Zope is not able to do it automatically.

Thank you,

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


[Zope3-Users] Vocabularies and Zope3-svn

2006-03-21 Thread Frank Burkhardt
Hi,

I've got some simple vocabularies like this one:

[vocabularies.py]
class RedirectTargetTypes(SimpleVocabulary):
   def __init__(self,context):
  targettypes={
 'generic url':_(uArbitrary URL),
 'local uid':_(uLocal UID or Permalink),
 'local url':_(uLocal URL reference)
  }
  terms=[SimpleTerm(code,title=title) for (code,title) in 
targettypes.items()]
  SimpleVocabulary.__init__(self,terms)

[configure.zcml]
   vocabulary
  factory=.redirect.vocabularies.RedirectTargetTypes
  name=Redirect targets
   /



After the latest svn-update, I always get this warning:



/var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml:26: 
DeprecationWarning: The 'vocabulary' directive has been deprecated and will
be removed in Zope 3.5.  Use the 'utility' directive instead to register the
class as a named utility:
  utility
  provides=zope.app.schema.interfaces.IVocabularyFactory
  component=redirect.vocabularies.RedirectTargetTypes
  name=Redirect targets
  /
  vocabulary



Unfortunately, when replacing the old 'vocabulary' by the new 'utility' 
directive,
I get this error:



  File /opt/zope3-svn/zope3/src/zope/component/site.py, line 241, in 
provideUtility
raise Invalid(The registered component doesn't provide 
zope.configuration.config.ConfigurationExecutionError: 
zope.component.interfaces.Invalid:
The registered component doesn't provide the promised interface.
  in:
  File 
/var/lib/zope3/instance/mpgsite-test/lib/python/redirect/configure.zcml, line 
26.1-30.3
utility
component=.redirect.vocabularies.RedirectTargetTypes
provides=zope.app.schema.interfaces.IVocabularyFactory
name=Redirect targets
/

I tried some hours modifying the RedirectTargetTypes class with implements
and classProvides but it didn't work. How am I supposed to write a simple
vocabulary the new way? Will it be 100% compatible to old style vocabularies
(e.g. run on Zope 3.2)?

Regards,

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


Re: [Zope3-Users] Vocabularies and Zope3-svn

2006-03-21 Thread Frank Burkhardt
Hi,

On Tue, Mar 21, 2006 at 07:49:21AM -0500, Stephan Richter wrote:
 On Tuesday 21 March 2006 07:34, Frank Burkhardt wrote:
  I tried some hours modifying the RedirectTargetTypes class with
  implements and classProvides but it didn't work. How am I supposed to write
  a simple vocabulary the new way?
 
 classProvides(zope.app.schema.interfaces.IVocabularyFactory) inside your 
 factory class works. I have this myself yesterday.

My problem was not related to vocabularies but arose from a bug in
zope.schema._field.Dict - which I just Collected.

Thank you very much,

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


Re: [Zope3-Users] Grants to unathenticatedPrincipal

2006-03-20 Thread Frank Burkhardt
Hi,

On Sat, Mar 18, 2006 at 10:32:39AM +, Rupert Redington wrote:
 When I try to make a permission or role based grant to zope.anybody
 through zcml I fail with:
 
  File /home/rupert/Zope3/lib/python/zope/app/security/principal.py,
 line 50, in checkPrincipal
 raise ValueError(Undefined principal id, principal_id)
 zope.configuration.config.ConfigurationExecutionError:
 exceptions.ValueError: ('Undefined principal id', 'zope.anybody')
 
 But the principal is defined in principals.zcml...
 If I try to overrride 'zope.anybody' by declaring my own
 unauthenticatedPrincipal in overrides.zcml my grant fails in a similar
 manner.
 
 Is it possible to make grants to the unauthenticatedPrincipal?

Yes.

 What am I missing this time?

You most probably tried to grant before defining the principal.
Have a look at etc/site.zcml - securitypolicy.zcml is processed
before principals.zcml . Placing your 'grant' somewhere
behind those two includes should work.

Regards,

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


[Zope3-Users] Check permissions

2006-03-17 Thread Frank Burkhardt
Hi,

how can I test, if the current principal (e.g. by being member in a special
group) has a given permission on a given content object?

Maybe something like this:

 if 'zope.ManageContent' in self.context.permissions():
...

This should include all permission defined in ZCML *and* all permission
granted in ZMI.

Thank you for all hints.

Regards,

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


Re: [Zope3-Users] skin concepts

2006-03-17 Thread Frank Burkhardt
Hi,

On Fri, Mar 17, 2006 at 08:52:26AM +0100, Lorenzo Gil Sanchez wrote:

 I want to understand some concepts involved in skin development and I
 haven't found any resource to read about this. I noticed that there is
 no skin package inside the Zope codebase and so I couldn't find any
 README.txt file as in other packages.

Have a look at zope.app.rotterdam (deprecated AFAIK) and zope.app.boston.

[snip]

 So here are my questions:
 
 - What is the default view that is applied to a content object? If I
 have something like this in my configure.zml:
 
   page
   for=mypackage.mycontenttype
   name=index.html
   permission=zope.View
   layer=mylayer
   template=index.pt/
 
  how do I make it the default view for objects of mycontenttype?

defaultView
for=mypackage.mycontenttype
name=index.html
/

  Related question: what is the default view for the root object in a
 zope instance? I have seen how to configure the default skin in a
 configuration file inside /etc but I don't know how Zope knows what view
 to apply if none is provide explicitly in the URL

In this case the 'defaultView' is used. The root object is just a
Folder - the default view is '@@index.html'. Just put an object
'index.html' into the root folder (or in any folder) to have it
shown by default.

 - What are the dialog_macros, view_macros, skin_macros and friends? I
 know that they are ZPT macros but how are they related? Which one is
 taken in each view?

A template is always a whole webpage - mo macro is applied magically.
You have to include macros explicitely:

div metal:use-macro=context/@@[macro-view]/[macro]
... my little template...
/div

[macro-view] is the macro-package - e.g. standard_macros or view_macros.
You can define as much as you like by adding templated page-zcml
directives for your layer and marking them es macro packages.
(see zope.app.basicskin.standardmacros.StandardMacros.macro_pages)

 where is this wired? I've seen the basicskin package
 of the Zope codebase and the file standardmacros.py but I don't
 understand how it works.
 
 - In my template.pt file I have defined a macro called 'page' and I just
 noticed that changing it to another name makes my template not being
 called. So I assume someone is doing something like metal
 use-macro=page but I'm too curious to trust magic: I want to know how
 the internals of this mechanism work :)

AFAIK it's just a standard to use page to render a view as part of
a management interface and to use view to render it standalone.

Regards,

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


Re: [Zope3-Users] Accessing sub objects view class?

2006-03-16 Thread Frank Burkhardt
On Wed, Mar 15, 2006 at 10:22:02AM -0800, Mats Nordgren wrote:
 I'm trying to figure out how to access a sub objects view class.
 
  
 
 1. div metal:fill-slot=body
 
 2. h4 tal:content=context/titleTitle/h4
 
 3.   div tal:content=structure view/renderDescriptionDescription/div
 
 4.   div tal:define=sections view/getSections
 
 5. div tal:repeat=item sections
 
 6.   div metal:use-macro=item/atatview.html/sectionmacro
 
 7. span metal:fill-slot=titlespan tal:content=item/title
 //span
 
 8. span metal:fill-slot=descriptionspan
 tal:content=item/description //span
 
 9.   /div
 
 10./div
 
 11.  /div
 
 12./div
 
  
 
 I'm trying to format the description of subobject 'item' on line 8 with its
 renderDescription function, just like parent object on line 3, but can't
 seem to figure out how.  Perhaps I'm going about it completely wrong.  Any
 help appreciated.

You need to specify the view, you want to use on item - e.g. 'view.html'.

Try this:

span tal:content=item/@@view.html/renderDescription

Regards,

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


Re: [Zope3-Users] Problem with XHTML in Pagetemplates

2006-03-06 Thread Frank Burkhardt
Hi,

On Fri, Mar 03, 2006 at 11:35:58PM +, Peter Bengtsson wrote:
 
 On 3 Mar 2006, at 14:08, Frank Burkhardt wrote:
 
 Hi,
 
 I try to create XHTML documents from Pagetemplates but unfortunately
 tags are not always closed correctly. Example:
 
  br /
 
 is Rewritten to
 
  br
 
 How did you do that?
 Are you sure you haven't just used View selections source in Firefox?

It was really a firefox problem. When I chose to save the webpage for
uploading it to the w3c-validator, firefox replaced some tags invalidating
the xhtml. The page fetched by wget was fine.

Thank you Peter,

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


[Zope3-Users] Accessing an attribute of 'context'

2006-02-20 Thread Frank Burkhardt
Hi,

How can I access an attribute of a BrowserView's context if the
attribute's name is not hardcoded?

Example:

 Works: self.context.myattribute
 
 Works: removeSecurityProxy(self.context).__getattribute__('myattribute')

What I want to do:
 
 Doesn't work: self.context.__getattribute__('myattribute')


Regards,

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


Re: [Zope3-Users] Lists dont accept default values

2006-02-16 Thread Frank Burkhardt
Hi,

On Wed, Feb 15, 2006 at 06:18:48PM +0100, Florian Lindner wrote:

[snip]

  I wrote a schema like this to have a list of objects on a content object:
 
   class IMyContent(Interface):
  mynumbers=List(
 title=_(uCool Numbers),
 required=True,
 value_type=Int(
  title=_(integer)
 )
 default=[1,2,3,5,7]
  )
 
 I think the default property expects one item of your list, so either 1, 2, 
 3, 
 5 or 7, not all of them.

No it doesn't. default=1 generates this error:

 ConfigurationError: ('Invalid value for', 'mynumbers', (1, type 'list'))

 If you want to define the set of selectable values you maybe rather want to 
 use a Choice field and specify the values property. Or set a Choice field as 
 value for value_type.

I don't really need Int as list items but some more complex objects.
This works quite well - except of the missing default.

Regards,

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


[Zope3-Users] Lists dont accept default values

2006-02-15 Thread Frank Burkhardt
Hi,

I wrote a schema like this to have a list of objects on a content object:

 class IMyContent(Interface):
mynumbers=List(
   title=_(uCool Numbers),
   required=True,
   value_type=Int(
title=_(integer)
   )
   default=[1,2,3,5,7]
)
myline=TextLine(
   title=_(A line of text),
   required=True,
   default=u'default test'
)

I'm using an 'addform' to add self made objects to my site but unfortunately
the list mynumbers is not initialized with those 5 default numbers. The
default value of myline is displayed correctly on the add form.

Does anyone know, how this can be fixed?

Regards,

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


[Zope3-Users] test() in TALES in Zope3

2006-02-01 Thread Frank Burkhardt
Hi,

in Zope2 there's a test() method that can be used in TAL (*). Is there something
comparable in Zope3?

I know how to write such a method but how to make it available in the
namespace of TALES-python:-expressions? I would like to write expressions
like this:

div tal:attributes=class python: 'foo' + test(condition == True,' bar','') /

Is this possible?

Regards,

Frank

(*) found it here:
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AdvZPT.stx
(look for 'test(' )
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] test() in TALES in Zope3

2006-02-01 Thread Frank Burkhardt
On Wed, Feb 01, 2006 at 09:04:36AM +0100, Frank Burkhardt wrote:

[snip]

 div tal:attributes=class python: 'foo' + test(condition == True,' bar','') 
 /
 
 Is this possible?

Impressing simple solution :-) .

Thank you Andreas and Igor.

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


Re: [Zope3-Users] Permissions of a given object

2006-01-17 Thread Frank Burkhardt
Hi,

On Sun, Jan 15, 2006 at 11:20:47AM -0500, Stephan Richter wrote:
 On Thursday 12 January 2006 08:13, Frank Burkhardt wrote:
  but the problem remains: canAccess returns True for all inaccessible
  objects.
 
 It is hard to guess where your setup is wrong. Does it not work for unit 
 tests, ftests and/or the full application?

The full application.

In a browser:view I want to query my Catalog to return a list of objects:

 list = catalog.searchResults(content='findme')

list contains a list of objects containing the word 'findme'. Now I
want to filter the list to contain only obj, the current principal
has access to.

 permitted_list=[]
 for obj in list:
if canAccess(obj,'__call__'):
   permitted_list.append(obj)

But there's no security proxy wrapping 'obj' s from 'list'.

How do I securityproxify 'obj' before being checked by canAccess so that the
result of canAccess reflects if the current principal is allowed to access
'obj' ?

Maybe I'm completly wrong and there's another way to filter searchresults
for objects, the user has access to?

Regards,

Frank


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


Re: [Zope3-Users] Permissions of a given object

2006-01-17 Thread Frank Burkhardt
Hi,

On Tue, Jan 17, 2006 at 10:53:12AM -0500, Gary Poster wrote:

[snip]

 The meaning of objects a user can access varies significantly from
 application to application.  You will probably want to optimize this
 filter by creating an index eventually.  For some policies and questions,
 this might be hard to do well.  We'll be releasing an index that does this
 sort of thing for one kind of use case soon, but it doesn't precisely
 match what you are doing here. 

 You'll probably want to think about this problem for your app and see how
 you can index the data.

Even if would write an index for this - I would still need some method to
check, if a given principal is allowed to access a given object.

Finally, I found a solution:

 from zope.security.checker import ProxyFactory
 list=catalog.searchResults(content='findme');
 permitted_list=[]
 for obj in list:
defaultview=zapi.getDefaultViewName(obj,self.request)
try:
   
view=zapi.queryMultiAdapter((ProxyFactory(obj),self.request),name=viewname)
   permitted_list.append(view)
except Unauthorized:
   Don't list this one

Regards,

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


Re: [Zope3-Users] Permissions of a given object

2006-01-12 Thread Frank Burkhardt
Hi,

On Thu, Jan 12, 2006 at 07:19:02AM -0500, Stephan Richter wrote:

[snip]

  But canAccess never fails here - even if the object is inaccessible.
 
 canAccess() returns a boolean unless there is no security declaration at all.

I changed the code fragement to

 for obj in catalog.searchResults(content=searchquery):
view=zapi.queryMultiAdapter((obj,self.request),name='view.html')
if canAccess(view,'__call__'):
   search_results.append(obj)
else:
   object inaccessible

but the problem remains: canAccess returns True for all inaccessible objects.

Regards,

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


[Zope3-Users] TextIndexNG3 and Zope3

2005-12-29 Thread Frank Burkhardt
Hi,

currently I'm trying to use TextIndexNG3 in Zope3. I'm able to add a
Ting3 Index to my catalog but there are some problems:

1. After I added a single object, the catalog statistic (Advanced-Tab) shows
   a table like this:

index | document count | word count
--++---
textindex | 1  | 15
ting3 | 1  | 1

   Why is TextIndexNG3's wordcount 1? The object I'm trying to index
   contains 15 words.

2. Where am I supposed to enable/disable all the ting3-features (i.e. 
   stemming)? There are no configuration options when I add the index to the
   catalog.

Thanks in advance for any hint.

Regards,

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


[Zope3-Users] Permissions of a given object

2005-12-14 Thread Frank Burkhardt
Hi,

when I search using a catalog, I get a list of persistent objects
but maybe there are objects among them, the calling user
doesn't have permissions for.

How do I check, if the current user (the one calling the view
which queries the catalog) is allowed to view an object?

How do I change permissions of a persistent object in python
(not using the ZMI)?

Thank you for any hint.

Regards,

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


Re: [Zope3-Users] Re: What's the rationale of @@ ? Was: index.html

2005-12-13 Thread Frank Burkhardt
Hi,

On Tue, Dec 13, 2005 at 02:02:05PM +0100, Andreas Elvers wrote:
 Hi all,
 
 what the rationale of @@ anyway ? I've searched for a definition for
 this in the Developer Handbook and elsewhere but it's hard to search
 for @@ and view.

(To all Gurus: Please correct me, if I'm wrong)

@@ marks a given path component explicitely as a view of the previous object.

Example:

http://zopeserver/contents.html 

Could mean either The object named 'contents.html' in the root folder or
(if there is no such object) The 'contents.html' view (List of contained
objects) of the root folder - the object is preferred.

http://zopeserver/@@contents.html

Will always display the list of contained objects of the root folder - no matter
if there's a object 'contents.html' or not.

I'm maintaining a wiki which tries to answer all those little questions around
zope3. It's in german (Sorry, my employer depends on it):

  http://fbo.no-ip.org/cgi-bin/twiki/view/Zope/AtAt

Regards,

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


Re: [Zope3-Users] The page that you are trying to access...

2005-12-12 Thread Frank Burkhardt
On Thu, Dec 08, 2005 at 05:45:08PM +0100, Dominik Huber wrote:
 Frank Burkhardt wrote:
 
 Hi,
 
 When I request a non-existing page from a zope3-server,
 I get this message:
 
   The page that you are trying to access is not available
   Please note the following:
   1. You might have misspelled the url
   2. You might be trying to access a non-existing page
 
 How can this page be customized?
 
 use the overrides.zcml mechanism, reregistering an other page for INotFound:
 
  page
  for=zope.publisher.interfaces.INotFound
  name=index.html
  permission=zope.Public
  template=notfound.pt
  class=zope.app.exception.browser.notfound.NotFound
  /

Thank you - it's working.

Regards,

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


[Zope3-Users] Sourcetext-mux

2005-11-09 Thread Frank Burkhardt
Hi,

I found a code fragment in an example-application which enables a
View-Object to render a SourceText using a renderer of the user's choice.

class ViewClass(object):
def render(self):
entry_text = zapi.createObject(None,
   self.context.renderer,
   self.context.text)
view = zapi.getView(removeAllProxies(entry_text), '', self.request)
result = view.render()

context.renderer contains a token of the 'SourceTypes'-Vocabulary (i.e.
'zope.source.rest'), context.text is the text to be rendered. The 'result' 
should be some
kind of html (xhtml preferred :-) ).

Zope Complains about this code, telling me, not to use zapi.getView() but 
zapi.getMultiAdapter()
but there's no hint, what parameters to use for getMultiAdapter.

Does anyone know the correct getMultiAdapter()-line - maybe with an 
explaination?

Thank you,

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


Re: [Zope3-Users] View with template

2005-11-02 Thread Frank Burkhardt
Hi,

On Mon, Oct 31, 2005 at 08:51:58AM +0100, Dominik Huber wrote:

[snip]

 How can Zope be forced to use the template instead of __call__ing
 the TestView-Object?
  
 
 If you use the the browser:form, browser:edit and/or browser:add 
 directive your TestView will be mixed in automatically during the setup. 
 In your example you are going to overwrite the __call__ method of the 
 mixed-in base class which is invoking the template. If you like to 
 overwrite the __call__ method, you have to call you base class too:
 
 class TestView(object):
  def __call__(self):
# do something else
return super(TestView, self).__call__()

Thank you - that's what I was looking for.

Regards,

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


[Zope3-Users] View with template

2005-10-28 Thread Frank Burkhardt
Hi,

a short introduction first:

I'm Frank Burkhardt, working at the Max Planck Institute in Germany. My
employer wants a new website to replace the old one (www.cbs.mpg.de - yes,
it looks really really ugly). We chose Zope3 to implement it.
Maybe there will be one or two questions on the way which is the reason
why I joined this list :-) .


Here is the first one:

I assigned a view to my brandnew content class:

  browser:page
 for=.test.ITest
 name=index.html
 permission=zope.Public
 class=.test.TestView
 template=view.pt
  /

This is what I think this xml-statement should do:

When http://zope/test/index.html is called, the template
view.pt is evaluated which has access to the View-class
TestView.

view.pt:

html metal:use-macro=context/@@standard_macros/view
div metal:fill-slot=body
div tal:replace=view/div
/div
/html

But whenever I define TestView.__call__ the template is not evaluated but
the result of TestView.__call__ is returned directly.

How can Zope be forced to use the template instead of __call__ing
the TestView-Object?

Regards,

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