Re: [Zope3-Users] Principal annotations

2006-03-20 Thread Stephan Richter
On Wednesday 08 March 2006 03:32, Shane Hathaway wrote:
 Chapter 27 of the Zope 3 book and the docstring for IPrincipal in Zope
 3.2 both suggest Zope has the ability to provide a browser view of
 principal annotations.  That would be a really great bit of
 functionality to have!  Unfortunately, AFAICT, the system doesn't work
 at all in Zope 3.2.  The Zope 3 book says you have to create an
 Authentication Service, but no such thing exists anymore.

Unfortunately, this is correct. The PAS is gone. It was one of those bits in 
the book that I knew would be a problem with Zope 3.1, but could do nothing 
about. :-(

 Instead, I created Pluggable Authentication Utility and put a principal
 folder inside it.  But principals created this way are InternalPrincipal
 objects which do not implement IPrincipal, so they don't have the extra
 view I registered.  I could find no other way to visit a user object in
 the management interface.  Therefore, views of IPrincipal are currently
 never used.

Okay. IPrincipal is used though. The strategy changed from PAS to PAU. In PAS 
a principal always existed, once you created it. In PAU, only information 
about the principal is stored and the principal (providing IPrincipal) is 
created once the authentication was successful.

 Was this an accident?  Did it work at one time?  Are there plans to make
 principal annotation views work again?  And how can I edit user
 annotations in the meanwhile?

The principal annotation views (can you actually give me some names?) could be 
easily fixed by working with IPrincipalInfo objects instead IPrincipal 
objects. This step should not be too hard.

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


Re: [Zope3-Users] Principal annotations

2006-03-11 Thread Gary Poster


On Mar 11, 2006, at 3:14 AM, Thierry FLORAC wrote:


On Thu, 2006-03-09 at 01:14 -0700, Shane Hathaway wrote:
Your idea of annotating InternalPrincipals rather than Principals  
seems

to work, but I apparently did something wrong, because edited
annotations don't persist!  I can save edits, but when I reload the
page, they're gone.  I don't know why.


As said in a previous (and un-replied :-( !) post a few days ago, I  
have
the same kind of problem with an adapter using annotations : if I  
set my

attributes using a property attribute, the setter is not called and
modifications are lost when page is reloaded ; I have to call the  
setter
directly (after modifying the interface, of course) from my adapter  
for

modifications to be stored...


I haven't had time to read much or reply, so these may not be what  
you and Shane are talking about, but I just saw this...


- yes, don't annotate principals.  principal objects are not  
persistent, and like the Zope 2 PAS are created and discarded within  
a request.  annotating internal principals is not recommended either:  
it won't work with other plugin designs.  Use principal annotations.   
Make sure that the adapter providing IAnnotations for principals  
returns the principal annotations.  (I thought I had done this for  
Zope 3, but maybe I just did it for some internal work...)


- Thierry, send me a link to your email and I'll try to look at it  
(especially if it is short :-) ).  It could be that you are not using  
a persistent-aware data structure (PersistentDict or a BTree).  We  
successfully do the sort of thing you seem to be describing, so I  
suspect some disconnect.


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


Re: [Zope3-Users] Principal annotations

2006-03-09 Thread Tom Dossis

Shane Hathaway wrote:


Alternatively, it may possible to setup an adapter for
IInternalPrincipal to IPrincipal ?


I tried that first, but it got messy.  IPrincipal needs an id, but
InternalPrincipal doesn't know its own id; only the folder that contains
it knows.  However, the folder has no method for giving me the id of an
InternalPrincipal, so the encapsulation isn't complete.  Maybe I should
work harder in this direction anyway.


zapi.getName(principal) will get the id managed by principal folder, e.g.

 site=root['mysite']
 sm = site.getSiteManager()
 pf = sm['tools']['PluggableAuthentication']['PrincipalFolder']
 pf
zope.app.authentication.principalfolder.PrincipalFolder object at 
0x419957ec

 list(pf)
[u'1']
 principal = pf['1']
 principal
zope.app.authentication.principalfolder.InternalPrincipal object at 
0x4183d3ec

 from zope.app import zapi
 zapi.getName(principal)
u'1'


Your idea of annotating InternalPrincipals rather than Principals seems
to work, but I apparently did something wrong, because edited
annotations don't persist!  I can save edits, but when I reload the
page, they're gone.  I don't know why.


I seem to recall encountering a similar problem once before, but 
unfortunately can't remember the details.  I do remember looking at the 
annotation code to work it out.




Thanks for helping me over a hurdle.  You'd think a Zope 2 veteran like
me would have little trouble with Zope 3


Maybe that has something to do with it.

We switched from zope2/cmf/plone to zope3 early on in the development of 
a new application.  Interestingly the python-only programmer back then 
took to zope3 much easier than zope2/cmf/plone.



get to know practically all of Zope 3 before I can really do anything
with it.  (I had to do the same thing with Zope 2.)



I'm sure it will all click into place soon enough.

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


Re: [Zope3-Users] Principal annotations

2006-03-09 Thread Tom Dossis

Shane Hathaway wrote:

Your idea of annotating InternalPrincipals rather than Principals seems
to work, but I apparently did something wrong, because edited
annotations don't persist!  I can save edits, but when I reload the
page, they're gone.  I don't know why.



A quick test, hope it helps...

 from zope.app.authentication.principalfolder import InternalPrincipal
 from zope.app.annotation import IAttributeAnnotatable
 from zope.interface import classImplements
 classImplements(InternalPrincipal, IAttributeAnnotatable)
 annotations = IAnnotations(principal)
 annotations
{}
 from persistent.dict import PersistentDict
 annotations['mykey'] = PersistentDict()
 info = annotations['mykey']
 info['abc'] = 123
 import transaction
 transaction.commit()
 ^D


 site=root['f2l']
 sm = site.getSiteManager()
 pf = sm['tools']['PluggableAuthentication']['PrincipalFolder']
 principal = pf['1']
 principal.__annotations__
BTrees._OOBTree.OOBTree object at 0x4190f974
 principal.__annotations__['mykey']
persistent.dict.PersistentDict object at 0x4178496c
 principal.__annotations__['mykey']['abc']
123


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


Re: [Zope3-Users] Principal annotations

2006-03-09 Thread Shane Hathaway
Tom Dossis wrote:
 Shane Hathaway wrote:
 Thanks for helping me over a hurdle.  You'd think a Zope 2 veteran like
 me would have little trouble with Zope 3
 
 Maybe that has something to do with it.
 
 We switched from zope2/cmf/plone to zope3 early on in the development of
 a new application.  Interestingly the python-only programmer back then
 took to zope3 much easier than zope2/cmf/plone.
 
 get to know practically all of Zope 3 before I can really do anything
 with it.  (I had to do the same thing with Zope 2.)
 
 I'm sure it will all click into place soon enough.

Well, I've come to realize I only had a lot of success with Zope 2 when
I worked on it full time.  Now I have other priorities, so Zope 2 only
gets a little of my attention.  I hoped that I could accomplish more in
less time with Zope 3, but it certainly hasn't worked out that way.  I'm
sure I would enjoy working with Zope 3 full time, but working with Zope
3 in my hobby time is not fun at all.

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


[Zope3-Users] Principal annotations

2006-03-08 Thread Shane Hathaway
Chapter 27 of the Zope 3 book and the docstring for IPrincipal in Zope
3.2 both suggest Zope has the ability to provide a browser view of
principal annotations.  That would be a really great bit of
functionality to have!  Unfortunately, AFAICT, the system doesn't work
at all in Zope 3.2.  The Zope 3 book says you have to create an
Authentication Service, but no such thing exists anymore.

Instead, I created Pluggable Authentication Utility and put a principal
folder inside it.  But principals created this way are InternalPrincipal
objects which do not implement IPrincipal, so they don't have the extra
view I registered.  I could find no other way to visit a user object in
the management interface.  Therefore, views of IPrincipal are currently
never used.

Was this an accident?  Did it work at one time?  Are there plans to make
principal annotation views work again?  And how can I edit user
annotations in the meanwhile?

Shane

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


Re: [Zope3-Users] Principal annotations

2006-03-08 Thread Shane Hathaway
Shane Hathaway wrote:
 Was this an accident?  Did it work at one time?  Are there plans to make
 principal annotation views work again?  And how can I edit user
 annotations in the meanwhile?

No one knows, I guess.  After spending many days on a seemingly simple
problem, I've drawn a blank.

Shane

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


Re: [Zope3-Users] Principal annotations

2006-03-08 Thread Tom Dossis


Shane Hathaway wrote:

Shane Hathaway wrote:

Was this an accident?  Did it work at one time?  Are there plans to make
principal annotation views work again?  And how can I edit user
annotations in the meanwhile?


No one knows, I guess.  After spending many days on a seemingly simple
problem, I've drawn a blank.


Not that I've tried this myself (yet).

Re: the ZopeBook example, I'd change the annotation adapter from
IPrincipal to IInternalPrincipal..

adapter
  factory=.info.PrincipalInformation
  provides=.interfaces.IPrincipalInformation
  for=zope.app.authentication.principalfolder.IInternalPrincipal
  permission=zope.ManageServices
  /

I guess you'd also need to make the InternalPrincipal class annotatable,
 in your application configure.zcml, add...

content
 class=zope.app.authentication.principalfolder.InternalPrincipal
 implements
   interface=zope.app.annotation.IAttributeAnnotatable
   /
/content

Also in the example the browser:editform directive should be changed
from IPrincipal to IInternalPrincipal.

Good luck.
-Tom

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


Re: [Zope3-Users] Principal annotations

2006-03-08 Thread Tom Dossis

Tom Dossis wrote:


Shane Hathaway wrote:

Shane Hathaway wrote:

Was this an accident?  Did it work at one time?  Are there plans to make
principal annotation views work again?  And how can I edit user
annotations in the meanwhile?


No one knows, I guess.  After spending many days on a seemingly simple
problem, I've drawn a blank.


Not that I've tried this myself (yet).

Re: the ZopeBook example, I'd change the annotation adapter from
IPrincipal to IInternalPrincipal..



Alternatively, it may possible to setup an adapter for 
IInternalPrincipal to IPrincipal ?

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