Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
On Friday 08 April 2005 14:46, Florian Lindner wrote: > Am Freitag, 8. April 2005 14:28 schrieb Stephan Richter: > > On Friday 08 April 2005 14:23, Florian Lindner wrote: > > > Ok, they seem to pass! > > > > > > Hurra! :-):-) > > > > Now you just have to add tests for your new code. :-):-) > > The tests I've added in the README.txt are not sufficient? > > >>> manager.autoCreateAssignment = True > >>> homeFolder = manager.getHomeFolder('florian') > >>> 'florian' in manager.assignments > True > >>> 'florian' in baseFolder > True > > > They pass without problems. Oh, I did not see those. That will suffice, yes, Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
Am Freitag, 8. April 2005 14:28 schrieb Stephan Richter: > On Friday 08 April 2005 14:23, Florian Lindner wrote: > > Ok, they seem to pass! > > > > Hurra! :-):-) > > Now you just have to add tests for your new code. :-) The tests I've added in the README.txt are not sufficient? >>> manager.autoCreateAssignment = True >>> homeFolder = manager.getHomeFolder('florian') >>> 'florian' in manager.assignments True >>> 'florian' in baseFolder True They pass without problems. Florian ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
On Friday 08 April 2005 14:23, Florian Lindner wrote: > Ok, they seem to pass! > > Hurra! :-):-) Now you just have to add tests for your new code. :-) Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
Am Freitag, 8. April 2005 14:05 schrieb Stephan Richter: > On Friday 08 April 2005 14:03, Florian Lindner wrote: > > But I can't really imagine that you (Stephan) as the original auther > > wrote no tests (while propagating tests so strongly in his book), so I > > somehow suspect the README.txt to act as test module and that the code > > samples are executable. But I got no idea how to run these tests (if they > > are tests). tests.py just reports that are no functional oder unit tests > > to run. > > from the Zope3 root: > > python test.py -vpu1 --dir src/zope/app/homefolder [EMAIL PROTECTED] ~/Zope3 $ python test.py -vpu1 --dir src/zope/app/homefolder Configuration file found. Running UNIT tests at level 1 Running UNIT tests from /home/florian/Zope3 1/22 ( 4.5%): /home/florian/Zope3/src/zope/app/homefolder/README.txt-- Ran 22 tests in 0.680s OK Ok, they seem to pass! Hurra! :-) Florian ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
On Friday 08 April 2005 14:03, Florian Lindner wrote: > But I can't really imagine that you (Stephan) as the original auther wrote > no tests (while propagating tests so strongly in his book), so I somehow > suspect the README.txt to act as test module and that the code samples are > executable. But I got no idea how to run these tests (if they are tests). > tests.py just reports that are no functional oder unit tests to run. from the Zope3 root: python test.py -vpu1 --dir src/zope/app/homefolder Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
Am Mittwoch, 6. April 2005 20:21 schrieb Stephan Richter: > On Wednesday 06 April 2005 16:22, Florian Lindner wrote: > > I you think that is a good idea, I would like (to try) to make the > > modifications at the HomeFolderManager. (as a junior job, practice and as > > well as a little bit giving back for all your help). > > Sure. Go ahead. Ok, I've made the changes and it works for me. The diff I've created with: [EMAIL PROTECTED] ~ $ svn diff Zope3/src/zope/app/homefolder/ > homefolder.diff is attached. I've also changed the readme to provide a example of the new feature. However the changes are not formally tested. The homefolder module has not contained any tests I could have used as a template and since I've never written tests of zope components I've skipped that for now. But I can't really imagine that you (Stephan) as the original auther wrote no tests (while propagating tests so strongly in his book), so I somehow suspect the README.txt to act as test module and that the code samples are executable. But I got no idea how to run these tests (if they are tests). tests.py just reports that are no functional oder unit tests to run. Regards, Florian Index: Zope3/src/zope/app/homefolder/interfaces.py === --- Zope3/src/zope/app/homefolder/interfaces.py (revision 29876) +++ Zope3/src/zope/app/homefolder/interfaces.py (working copy) @@ -44,10 +44,17 @@ createHomeFolder = Bool( title=_("Create Home Folder"), -description=_("Whether home folders should be created, if missing."), +description=_("Whether home folders should be created upon adding a assignment, if missing."), required=True, default=True) - + +autoCreateAssignment = Bool( +title=_("Auto create assignment"), +description=_("Whether assignment and folder should be created when " + "calling getHomeFolder, if not existing."), +required=True, +default=False) + homeFolderRole = Choice( title=_("Local Home Folder Role"), description=_("The local role that the user will have in " @@ -80,10 +87,14 @@ def getHomeFolder(principalId): """Get the home folder instance of the specified principal. -If the home folder does not exist and `autoCreateFolder` is set to -`True`, then create the home folder. During creation, the principal -should get manager rights inside the folder. +If a assignment does not exist and `autoCreateAssignment` is set to +`True`, then create the assignment and the homefolder. The homefolder +will always be created regardless of the value of createHomeFolder. +The folder will be given the same name like the principalId. + +During creation, the principal should get the rights specified in +homeFolderRole inside the folder. -If the home folder does not exist and `autoCreateFolder` is set to +If the home folder does not exist and `autoCreateAssignment` is set to `False`, then return `None`. """ Index: Zope3/src/zope/app/homefolder/homefolder.py === --- Zope3/src/zope/app/homefolder/homefolder.py (revision 29876) +++ Zope3/src/zope/app/homefolder/homefolder.py (working copy) @@ -35,6 +35,7 @@ # See IHomeFolderManager homeFolderBase = None createHomeFolder = True +autoCreateAssignment = False homeFolderRole = u'zope.Manager' def __init__(self): @@ -68,7 +69,10 @@ def getHomeFolder(self, principalId): """See IHomeFolderManager""" if principalId not in self.assignments: -return None +if self.autoCreateAssignment: +self.assignHomeFolder(principalId, create=True) +else: +return None return self.homeFolderBase.get(self.assignments[principalId], None) Index: Zope3/src/zope/app/homefolder/README.txt === --- Zope3/src/zope/app/homefolder/README.txt (revision 29876) +++ Zope3/src/zope/app/homefolder/README.txt (working copy) @@ -129,14 +129,27 @@ If you try to get a folder and it does not yet exist, `None` will be -returned. Remember 'dreamcatcher', which has an assignment, but not a folder? +returned if autoCreateAssignment is False. Remember 'dreamcatcher', which +has an assignment, but not a folder: >>> 'dreamcatcher' in baseFolder False >>> homeFolder = manager.getHomeFolder('dreamcatcher') >>> homeFolder is None True + +However, if autoCreateAssignment is True and you try to get a home folder +of a principal which has no assignment, the assignment and the folder +will be automatically created. The folder will always be created, regardless +of the value of createHomeFolder. The name of the folder will
Re: [Zope3-dev] Enhancement proposal for the HomeFolderManager
On Wednesday 06 April 2005 16:22, Florian Lindner wrote: > I you think that is a good idea, I would like (to try) to make the > modifications at the HomeFolderManager. (as a junior job, practice and as > well as a little bit giving back for all your help). Sure. Go ahead. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com