Re: [Zope3-Users] Programatically add plugins to PAU

2006-04-11 Thread Stephan Richter
On Wednesday 12 April 2006 02:39, Michael Howitz wrote:
> This is how we did it in a project:
> createAuthenticationUtils is called on handling the ObjectAddedEvent for
> the folder (which is programmatically made a site) which should contain
> the PAU.

Interesting. We did, of course, something similar too in our current project. 
This either means that (a) PAU is too hard to set up and/or (b) that we need 
another "helper" layer.

I would like to think the problem is (b), because I like the flexibility of 
PAU. The configuration package we wrote is step one, but it would be good to 
agree on a set of high-level helper functions too.

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] RE: principal folder subclassing

2006-04-11 Thread Stephan Richter
On Tuesday 11 April 2006 04:07, Pete Taylor wrote:
> if you create your own principal info like i did for these principals,
> you have to make sure you don't set title or description to None.  if
> they're set to none, attempting to grant on them fails because it
> attempts to "lower()" the NoneType.

Thanks for the follow up. Note that at least title is a required field, so you 
must provide one. If you implement your own component, always study the 
required interfaces carefully! We tries hard to always provide good 
documentation in those interfaces on how to implement them.

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] Programatically add plugins to PAU

2006-04-11 Thread Michael Howitz

Florian Lindner wrote:

Hello,
I've a PluggableAuthentication and want to add and register some plugins to 
it.


Adding works fine:

principal_folder = 
zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs")


pau["PrincipalFolder"] = principal_folder

and I think I can select it with:

pau.credentialsPlugins = [principal_folder]

but how to register it before?

And how do I select credential plugins?


This is how we did it in a project:
createAuthenticationUtils is called on handling the ObjectAddedEvent for 
the folder (which is programmatically made a site) which should contain 
the PAU.


HTH, mac

---

from zope.app.security.interfaces import IAuthentication
from zope.app.authentication.interfaces import IAuthenticatorPlugin
from zope.app.appsetup.bootstrap import ensureUtility
from zope.app.authentication.authentication import \
PluggableAuthentication
from zope.app.authentication.principalfolder import PrincipalFolder
from zope.app.authentication.groupfolder import \
GroupFolder, GroupInformation
from zope.app import zapi

from myproject import config

def addUtilityToPAU(pau, interface, utility_factory, id, name):
utility = utility_factory()
pau[id] = utility

reg_man = pau.registrationManager
reg = site.UtilityRegistration(name, interface, utility)
reg_man.addRegistration(reg)
reg.status = u'Active'

def _addGroupInformation(group_folder, id, title, description):
group = GroupInformation()
group.title = title
group.description = description
group_folder[id] = group

def createAuthenticationUtils(obj):
ensureUtility(obj, IAuthentication, '', PluggableAuthentication,
  copy_to_zlog=False)
auth = zapi.getUtility(IAuthentication)
auth.credentialsPlugins = (u'Session Credentials',)
addUtilityToPAU(auth, IAuthenticatorPlugin, PrincipalFolder,
'principal_folder', u'Benutzerverwaltung')
addUtilityToPAU(auth, IAuthenticatorPlugin, GroupFolder,
'group_folder', u'Rollenverwaltung')
auth.authenticatorPlugins = (u'Benutzerverwaltung',
 u'Rollenverwaltung',)
group_folder = auth['group_folder']
for group in config.company_groups:
_addGroupInformation(group_folder, group['id'],
 group['title'], group['description'])

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


Re: [Zope3-Users] Utilities / Adapters security - is access limited to interfaces?

2006-04-11 Thread Stephan Richter
On Tuesday 11 April 2006 06:59, Reinhold Strobl wrote:
> I have got a question on security:
> utitlities and adapters only have a simple security attribute (=permission)
> in the configuration directive, that means, I can't specifiy settings on
> attributes like with content components.
>
> But now what about access, if I have got the needed permission, can I
> access only the methods, attributes defined in the interface or can I
> access every attribute of the object?

Simply do not specify "permission" in the adapter directive and use the 
 directive to set your security the same way you do for other 
components, like content.

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] Concurrent data access in Zope

2006-04-11 Thread Stephan Richter
On Tuesday 11 April 2006 07:33, Andreas Jung wrote:
> > How is access synchronisation to such a structure handled in Zope? What
> > happens automatically? What do I have to do on my own?
>
> First come, first serves. There is no fancy synchronization. If two threads
> are trying to modify the same object then one thread will receive a
> WriteConflict error. It is up to the app to deal with these kind of errors.
> In the Zope 2 world Zope tries to re-do the current transaction for up to
> three times before the ConflictError is passed up to the application.

Same in Zope 3.

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] Re: Programatically add plugins to PAU

2006-04-11 Thread Stephan Richter
On Tuesday 11 April 2006 18:26, Andreas Elvers wrote:
> I use events to trigger post initialization of my content object.
> setUpMyapp is called by such a subscriber. This example is *not* complete.
> Maybe its helpful.

I have developed a small post-initialization configuration system last week 
that I plan to check in. We use it for exactly this use case: Setup a site 
after initialization.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Programatically add plugins to PAU

2006-04-11 Thread Andreas Elvers

Hi Florian,

I use events to trigger post initialization of my content object. setUpMyapp is 
called
by such a subscriber. This example is *not* complete. Maybe its helpful.

To register utilities I use a helper function 'addLocalUtility'.

from zope.app import zapi
from zope.app.container.interfaces import INameChooser
from zope.app.component.interfaces.registration import ActiveStatus
from zope.app.component.interfaces import ISite
from zope.app.utility import UtilityRegistration


def addLocalUtility(site, name, iface, utility, 
package='default',folderishUtility=None):
"""Add a utility to a site

The utility is added to the package and activated.
If folderishUtility is given, this Folder is treated as SiteManagementFolder
and the utility is added and registered in this SiteManagementFolder.
"""

# preconditions
if not ISite.providedBy(site):
raise TypeError('ISite required.')

# get site manager and site management folder
sitemanager = site.getSiteManager()
if folderishUtility != None:
default = folderishUtility
else:
default = sitemanager[package]

# add utility to site management folder
chooser = INameChooser(default)
folder_name = chooser.chooseName(utility.__name__, utility)
default[folder_name] = utility

# do utility registration
path = zapi.getPath(utility)
registration = UtilityRegistration(name, iface, utility)
key = default.registrationManager.addRegistration(registration)

zapi.traverse(default.registrationManager, key).status = ActiveStatus
return zapi.traverse(sitemanager, path)


This is the setup code called by event subscriber. Should be placed near the 
Myapp class.

def setUpMyapp(context):

# create a LocalSiteManager
sm = site.LocalSiteManager(context)
# and assign it to Myapp folder
context.setSiteManager(sm)

context.dataBaseConnectionString = context.dataBaseConnectionString

addLocalUtility(context,'psycopg',
IZopeDatabaseAdapter,
PsycopgAdapter(context.dataBaseConnectionString))

addLocalUtility(context,'sessionManager',
ISessionDataContainer,
PersistentSessionDataContainer())

addLocalUtility(context,'Search',
ISearch,
Search())

# adding PluggableAuthentication utility
pluggable = addLocalUtility(context,'',
IAuthentication,
PluggableAuthentication(context.name + '.'))

# adding PlugAuth GroupFolder utility
groupFolder = addLocalUtility(context,'groups',
  IAuthenticatorPlugin,
  groupfolder.GroupFolder('group.'),
  folderishUtility=pluggable)

# adding PlugAuth PrincipalFolder utility
principalFolder = addLocalUtility(context,'principal',
  IAuthenticatorPlugin,
  PrincipalFolder('principal.'),
  folderishUtility=pluggable)

# adding SessionCredentials utility
sessionCredentials = addLocalUtility(context,'sessionCredentials',
 ICredentialsPlugin,
 SessionCredentialsPlugin(),
 folderishUtility=pluggable)

# Plugin setup
pluggable.credentialsPlugins = ('sessionCredentials',)
pluggable.authenticatorPlugins = ('groups', 'principal')

# setup groups
localGroup = groupfolder.GroupInformation("Local user group")
centralGroup = groupfolder.GroupInformation("Central user group")
groupFolder['local'] = localGroup
groupFolder['central'] = centralGroup

# grant roles to groups

prinRoleManager = IPrincipalRoleManager(context)
prinRoleManager.assignRoleToPrincipal(pluggable.prefix+'role.CentralEditor',
  pluggable.prefix+'group.central')

# FIXME: set up default users for devlopment purposes only

principalFolder[u'admin'] = InternalPrincipal('admin','x','admin',
 passwordManagerName='SHA1')
principalFolder[u'local'] = InternalPrincipal('local','x','local',
 passwordManagerName='SHA1')
principalFolder[u'central'] = InternalPrincipal('central','x','central',
 passwordManagerName='SHA1')

# setting breakpoint
import pdb; pdb.set_trace()
# FIXME: This does not work. see my previous post 2006/04/11 on zope3.user
#localGroup.principals = [pluggable.prefix+'principal.local',]
#centralGroup.principals = [pluggable.prefix+'principal.central',]

prinRoleManager.assignRoleToPrincipal('zope.ManageContent','principal.admin')

___

Re: [Zope3-Users] Container Contents View

2006-04-11 Thread Tom Dossis

David Johnson wrote:
This is probably a trivial question.  I would like have a container 
contents view, but I do not want it to be index.html (which is 
apparently the default?).  However the ZCML I’m using always seems to 
define the view as index.html.  What am I doing wrong this time?


  


Leave out the index, e.g.

   

You can then set up your own page/view for index.html if desired.
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Container Contents View

2006-04-11 Thread David Johnson








This is probably a trivial question.  I would like have a container
contents view, but I do not want it to be index.html (which is apparently the
default?).  However the ZCML I’m using always seems to define the view as
index.html.  What am I doing wrong this time?

 

  

  for="">

  index="zope.View"

  contents="zope.View"

  add="zope.ManageContent"

  />

 

 

--

David Johnson

 






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


[Zope3-Users] Programatically add plugins to PAU

2006-04-11 Thread Florian Lindner
Hello,
I've a PluggableAuthentication and want to add and register some plugins to 
it.

Adding works fine:

principal_folder = 
zope.app.authentication.principalfolder.PrincipalFolder(prefix = "cs")

pau["PrincipalFolder"] = principal_folder

and I think I can select it with:

pau.credentialsPlugins = [principal_folder]

but how to register it before?

And how do I select credential plugins?

Thanks,

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


[Zope3-Users] Re: Search on Z3 collector broken

2006-04-11 Thread Michael Haubenwallner

Andreas Elvers wrote:

Hi,

trying to search the Zope3 collector gives me a 404. This is fixable by 
changing the URL from 
http://www.zope.org/Zope3-dev/collector_contents?searching=yep&SearchableText= 
...

to http://collector.zope.org ...
Re-getting the URL gives me the wanted search results.

- Andreas


Hi Andreas,
the issue is already reported and should be fixed soon.

For now please browse to:
http://www.zope.org/Collectors/Zope3-dev/

Searching and links should work from there.

Hth, Michael

--
http://zope.org/Members/d2m
http://planetzope.org

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


[Zope3-Users] Programmatically changing GroupInformation.principals

2006-04-11 Thread Andreas Elvers

Hi,

I'm trying to change GroupInformation.principals inside my application, 
but I'm getting PrincipalLookupErrors. Here's a demo:


The Demo is a folder with a Site that contains a PAU with one principal 
Mr. Test and a group called testgroup. Mr. Test is member of testgroup.


First we setup the demo in ZMI (taking a *deep* breath):

- create a folder 'Test'
- enter Test
- Make Site
- enter Test/++etc++site/default

- create PluggableAuthentication utility with Prefix = pauprefix.
- click register
- click add

- create PrincipalFolder with prefix = principal.
- click register
- Register as principalfolder and add
- add a PrincipalInformation: login = testuser, password=pass, title=Mr. 
Test


- go back to pau folder and add a GroupFolder prefix=group.
- register as groupfolder
- add a group: title=testgroup

- go back to pau folder and add groupfolder and principalfolder in 
Authenticator Plugins. Click change.


- from the navtree choose the groupfolder that resides in our pau folder.
- click on group 1 (this is actually the testgroup. Why using numbers ?)
- Under the headline "Principal Folder" click on Search.
- Select Mr. Test and click Apply.
- Now click Change at the bottom of the page.

Now stop zope and run debugzope.

# getting pau
>>> pau = 
app.root()['Test'].getSiteManager()['default']['PluggableAuthentication']

>>> group = pau['GroupFolder']['1']
>>> group.principals
('pauprefix.principal.1',)

Now: Why does this not work ?

>>> group.principals = ('pauprefix.principal.1',)
Traceback (most recent call last): ...
  File 
"/usr/local/zope-3.2.0/lib/python/zope/app/security/principalregistry.py", 
line 75, in getPrincipal

raise PrincipalLookupError(id)
zope.app.security.interfaces.PrincipalLookupError: 'pauprefix.principal.1'

Thanks for your help.
- Andreas

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


[Zope3-Users] Search on Z3 collector broken

2006-04-11 Thread Andreas Elvers

Hi,

trying to search the Zope3 collector gives me a 404. This is fixable by 
changing the URL from 
http://www.zope.org/Zope3-dev/collector_contents?searching=yep&SearchableText= 
...

to http://collector.zope.org ...
Re-getting the URL gives me the wanted search results.

- Andreas

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


Re: [Zope3-Users] Concurrent data access in Zope

2006-04-11 Thread Andreas Jung



--On 11. April 2006 13:26:10 +0200 Achim Domma <[EMAIL PROTECTED]> wrote:




How is access synchronisation to such a structure handled in Zope? What
happens automatically? What do I have to do on my own?



First come, first serves. There is no fancy synchronization. If two threads 
are trying to modify the same object then one thread will receive a 
WriteConflict error. It is up to the app to deal with these kind of errors. 
In the Zope 2 world Zope tries to re-do the current transaction for up to 
three times before the ConflictError is passed up to the application.


-aj


--
ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope & Plone development and consulting


pgproi5P5qfwI.pgp
Description: PGP signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Concurrent data access in Zope

2006-04-11 Thread Achim Domma

Hi,

I have a questions about concurrency, which came up during switching my 
head from realtional databases to ZODB:


I think about implementing a container-like data object which holds 
other data objects. To speed up access to the child objects I would 
implement some indexes using persistent btrees, which are managed and 
stored by the container object.


How is access synchronisation to such a structure handled in Zope? What 
happens automatically? What do I have to do on my own?


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


[Zope3-Users] Utilities / Adapters security - is access limited to interfaces?

2006-04-11 Thread Reinhold Strobl
Hi,

I have got a question on security:
utitlities and adapters only have a simple security attribute (=permission) in
the configuration directive, that means, I can't specifiy settings on attributes
like with content components. 

But now what about access, if I have got the needed permission, can I access
only the methods, attributes defined in the interface or can I access every
attribute of the object?

Thanks a lot!

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


[Zope3-Users] RE: principal folder subclassing

2006-04-11 Thread Pete Taylor
thought i'd answer my own question.  i apologize, one of those "i'm
going to bed so of course my brain figures it out" moments happen,
making me get up to write more code.

if you create your own principal info like i did for these principals,
you have to make sure you don't set title or description to None.  if
they're set to none, attempting to grant on them fails because it
attempts to "lower()" the NoneType.

sorry to send a question and a retraction on one another's heels.
--
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] principal folder subclassing

2006-04-11 Thread Pete Taylor
hi all...  i have a question about principalfolder derivatives. 
weirdest thing keeps happening...

I have a class that i derived from
zope.app.authentication.principalfolder.PrincipalFolder.  I've added
it to my PAU, even created principals in it without trouble.  but i've
been trying (and failing, currently) to create a login page that lets
me log in with that particular user.  i'm still working on that
though, and may send other questions about it later, but for now, i
found something else strange.

i was trying to add roles to the principal i have in my folder.  going
to grant, i hit "search" on the slot for ConsumerPrincipalFolder, and
it gave me a system error.  i thought that was strange, so i went back
and put in specific criteria.  still, same error.  this is a snip of
the relevant bits:

 Module zope.app.form.browser.source, line 244, in __call__
result.append('  \n%s' %
  Module zope.app.form.browser.source, line 254, in _renderResults
for value in results:
  Module zope.app.authentication.authentication, line 175, in search
for id in self.authplugin.search(query, start, batch_size):
  Module zope.app.authentication.principalfolder, line 300, in search
if (search in value.title.lower() or
AttributeError: 'NoneType' object has no attribute 'lower'

just to make sure, i put some debugging into principalfolder, raising
what self and query were at the time it hit line 300, and sure enough,
it was my principal folder implementation, and my query just as i
expected it.  so i pulled that debugging out, and went into zopectl
debug.  i got my principal folder from the site manager, and tried to
iterate over "cpf.values()"...  the output of my attempts is below:

>>> root = debugger.root()
>>> from zope.app import zapi
>>> sm = zapi.getSiteManager(context=root)
>>> cpf = sm['tools']['PluggableAuthentication']['ConsumerPrincipalFolder']
>>> for i, value in enumerate(cpf.values()):
... print i, value
...
0 
>>> query = {'search': '[EMAIL PROTECTED]'}
>>> generatorObj = cpf.search(query)
>>> for obj in generatorObj:
... print obj
...
Traceback (most recent call last):
  File "", line 1, in ?
  File "/opt/zope3/lib/python/zope/app/authentication/principalfolder.py",
line 300, in search
if (search in value.title.lower() or
AttributeError: 'NoneType' object has no attribute 'lower'

now, what i don't get is that cpf isn't 'NoneType"...  all search does
is take self, query, start, and batch_size and return a generator. 
cpf can't possibly be "NoneType" or it wouldn't have a method 'search"
to throw an error.

so i'm confused.  i tried it with the standard PrincipalFolder, but it
works fine, which isn't surprising.  but my ConsumerPrincipalFolder is
derived from PrincipalFolder...  only thing it does differently is
hold my ConsumerPrincipal's, which needed to be slightly different
than standard principals.

does anyone have any idea where i should start here?  i have other
issues to solve surrounding actually creating login pages and viewlets
and such, but in troubleshooting those, i ran into this...

Thanks for any help!
Pete

--
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Plone-developers] Re: [Zope3-Users] Re: [z3-five] zope.viewlet and zope.contentprovider - options for Zope 2 and Plone 3

2006-04-11 Thread Jean-Marc Orliaguet

Stephan Richter wrote:


On Monday 10 April 2006 08:50, Jean-Marc Orliaguet wrote:
 


Stephan Richter wrote:
   


On Sunday 09 April 2006 20:33, David Pratt wrote:
 


The Z2 integration will be started soon at a sprint soon. Viewlets and
portlets seem pretty synonymous and cpsskins provides a way to
manipulate portlets visually which is very nice.
   


Viewlets are not portlets! Portlets are much more restrictive and the
industry has a very specific meaning for the term, which differs from
both, Plone's and CPS skins', usage of the term.

Regards,
Stephan
 


Actually I've looked into creating a generic "viewlet" portlet that
would make it possible to reuse viewlets in cpsskins (for instance by
using the visual portlet editor). A feature that is missing is that
there is no easy way to find the list of registered viewlets. A viewlet
lookup mechanism would be needed, for instance a utility that returns a
list vocabulary items with viewlet's name and the factory.

also something that seems strange is that some viewlets are dependent on
viewlet managers:
   



There is nothing strange at all about that. Viewlet managers are very 
important for deciding which and how viewlets are shown. If you want viewlets 
without viewlet managers, then use content providers. BTW, I do use both in 
development depending on my needs.


 


see for instance: zope/app/boston/viewlets/toolbar:

class ToolBarViewlet(object):
   """I18n info viewlet."""

   implements(IToolBarViewlet)

   def macros(self, name):
   return self.manager.macros(name) <<

   def menus(self, menuId):
   return getMenu(menuId, self.context, self.request)


So if I want to render a toolbar viewlet I need to instanciate the
corresponding viewlet manager. I would understand this if I wanted to
render all viewlets in a given area of the page, but if I want to render
just one viewlet?
   



Use a content provider then.

 


Basically it introduces a cycle in the design: viewlet managers depend
on viewlets and viewlets depend on viewlet managers to be rendered.
   



Absolutely! This is the point. The API and communication between a viewlet 
manager and its viewlets is very well defined. This is a win. Again, just use 
content providers to have simple HTML snippets.


Regards,
Stephan
 



Hi Stephan,

I do understand this. My point was that to reuse what other developers 
already have created, not necessarily to create new content providers 
from scratch. For instance I look at zope.app.boston.viewlets, I see 3 
interesting viewlets:  'addinginfo', 'toolbar' and 'xmltree', none of 
which can be reused in other projects without instanciating a viewlet 
managers (which by the way are extremely specific to the boston skin).


an 'onion skin' type of design, would have been possible. Now, one has 
to buy the entire onion.


( ( ( ContentProvider ) Viewlet ) Viewlet manager )

regards
/JM

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