Re: [Zope3-Users] Authentication howto
Hi Torvald, I recommend you Philips,s zope3 book and specialy the security charpters that explain the zope3 auth mechanics widely. Here you are some notes about how to implement a user management system... 1) First of all you have to create and register a PAU Utillity in your siteManager. Read this code snippet: kelpi.com/script/9141b4 as you can see there, you have to handle the after creation event to create and register the pau utility. 2) The credentials are managed by the CookieCredentialsPlugin written by Philipp V. W. See: kelpi.com/script/c1c9a3 3) Here you have an example of a view for signing up proposals: kelpi.com/script/e2019a 4) In this example: kelpi.com/script/f49219 you can see an adapter that allows you to register a new user withing the user folder in PAU. If you need more lines of code or any other explanation, just tell me... Bye, Nando. -- http://www.nandoquintana.com/contact signature.asc Description: Esta parte del mensaje está firmada digitalmente ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Vedr. Re: [Zope3-Users] Authentication howto
Hi, I've uploaded you another piece of code: kelpi.com/script/c880ba There you have a view to handle login action. when auth is required zope redirects you to /loginForm.html I redirect then to /login where I prompt the user asking for user/pass. In this zcml: kelpi.com/script/fa9196 you can see the registration of some of the views that participates in the sign up /login dance. If you want to see all this code running: http://trac.kelpi.com/browser/trunk/kelpi this is the source code of kelpi.com Take a look at it... Bye, Nando. El mar, 12-06-2007 a las 00:08 +0200, Torvald Bringsvor escribió: Thanks for the samples you provided. Question: do you have any more samples on setting up for example a custom login screen (also with zcml code)? -- http://www.nandoquintana.com/contact signature.asc Description: Esta parte del mensaje está firmada digitalmente ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Evolution of ZoDB after changing python modules structure (moving content classes to another module)
Aleksander Kowalczyk wrote: On 6/8/07, Alek Kowalczyk [EMAIL PROTECTED] wrote: Alek Kowalczyk [EMAIL PROTECTED] writes: Hi, I moved my content class from mypackage.mymodule.MyContentClass into mypackage.mysubpackage.mymodule.MyContentClass. But when started Zope and went to visit an object I have previously created (of MyContentClass), I get: ComponentLookupError: ((persistent broken mypackage.mymodule.MyContentClass instance '\x00\x00\x00\x00\x00\x00\x02q', zope.publisher.browser.BrowserRequest instance I found a quite well working solution on http://mail.zope.org/pipermail/zodb-dev/2006-September/010382.html There was only one issue: this solution assumes that we have given a DB, while Zope evolve method receives already open connection. Unfortunately classFactory from DB is cached in Connection's private fields in constructor. Because of that I could not assign my custom 'renaming' class factory using: def evolve(context): #won't work! context.connection.db().classFactory = myClassFactory Instead I had to do some dirty private fields substitution in Connection's ObjectReader: def evolve(context): #this works nice context.connection._reader._factory = myClassFactory I shouldn't announce success too early. The solution works but only during first Zope run (i.e just after evolving the schema). Although classFactory returns proper class during evolve, the new class name is not saved in ZoDB, so after next unghosting object get old class names again. Here is my evolve script. I really don't know what more should I do to make Zope/ZoDB write the new class name in ZoDB. Can someone help me a bit... :) ? def convertingClassFactory(connection, moduleName, globalName): #convert class name to new one and return the class object def evolve(context): #dirty hack to substitute classFactory context.connection._reader._factory = convertingClassFactory root = context.connection.root().get(ZopePublication.root_name, None) for object in findObjectsMatching(root, lambda x: True): if hasattr(object, '_p_activate'): object._p_activate() object._p_changed = True Somebody correct me if I'm wrong I imagine you'd need to commit the transaction manually: def evolve(context): #dirty hack to substitute classFactory context.connection._reader._factory = convertingClassFactory root = context.connection.root().get(ZopePublication.root_name, None) for object in findObjectsMatching(root, lambda x: True): if hasattr(object, '_p_activate'): object._p_activate() object._p_changed = True import transaction transaction.commit() Hope that helps, Rupert ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Vedr. Re: [Zope3-Users] Authentication howto
I didn't know kelpi.com, that's a nice example of zope3 app !! I guess this hasn't been online for a long time? I've quickly looked at the code, and I have a question: what's the purpose of MyIntIds compared to the base IntIds? Is this some optimisation? Christophe Nando Quintana a écrit : Hi, I've uploaded you another piece of code: kelpi.com/script/c880ba There you have a view to handle login action. when auth is required zope redirects you to /loginForm.html I redirect then to /login where I prompt the user asking for user/pass. In this zcml: kelpi.com/script/fa9196 you can see the registration of some of the views that participates in the sign up /login dance. If you want to see all this code running: http://trac.kelpi.com/browser/trunk/kelpi this is the source code of kelpi.com Take a look at it... Bye, Nando. El mar, 12-06-2007 a las 00:08 +0200, Torvald Bringsvor escribió: Thanks for the samples you provided. Question: do you have any more samples on setting up for example a custom login screen (also with zcml code)? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Evolution of ZoDB after changing python modules structure (moving content classes to another module)
On Sun, Jun 10, 2007 at 09:14:24AM +0200, Aleksander Kowalczyk wrote: On 6/8/07, Alek Kowalczyk [EMAIL PROTECTED] wrote: Alek Kowalczyk [EMAIL PROTECTED] writes: Hi, I moved my content class from mypackage.mymodule.MyContentClass into mypackage.mysubpackage.mymodule.MyContentClass. But when started Zope and went to visit an object I have previously created (of MyContentClass), I get: ComponentLookupError: ((persistent broken mypackage.mymodule.MyContentClass instance '\x00\x00\x00\x00\x00\x00\x02q', zope.publisher.browser.BrowserRequest instance I found a quite well working solution on http://mail.zope.org/pipermail/zodb-dev/2006-September/010382.html There was only one issue: this solution assumes that we have given a DB, while Zope evolve method receives already open connection. Unfortunately classFactory from DB is cached in Connection's private fields in constructor. Because of that I could not assign my custom 'renaming' class factory using: def evolve(context): #won't work! context.connection.db().classFactory = myClassFactory Instead I had to do some dirty private fields substitution in Connection's ObjectReader: def evolve(context): #this works nice context.connection._reader._factory = myClassFactory I shouldn't announce success too early. The solution works but only during first Zope run (i.e just after evolving the schema). Although classFactory returns proper class during evolve, the new class name is not saved in ZoDB, so after next unghosting object get old class names again. Here is my evolve script. I really don't know what more should I do to make Zope/ZoDB write the new class name in ZoDB. Can someone help me a bit... :) ? def convertingClassFactory(connection, moduleName, globalName): #convert class name to new one and return the class object def evolve(context): #dirty hack to substitute classFactory context.connection._reader._factory = convertingClassFactory root = context.connection.root().get(ZopePublication.root_name, None) for object in findObjectsMatching(root, lambda x: True): if hasattr(object, '_p_activate'): object._p_activate() object._p_changed = True Note that findObjectMatching will not return all the persistent objects, but only those that are directly placed in containers. Other objects (e.g. ones stored in annotations) refer to your old classes, you'll need to do more. Stephan Richter once figured out how to do that for SchoolTool, IIRC it involved looping through all OIDs in the database and marking them as _p_changed. Marius Gedminas -- Whom the gods would destroy, they first teach BASIC. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.forms: Datamanger that combines values of multiple widgets
Hi, I've read the doctests of z3c.forms and have to say that the package is really impressive. Many things look a lot cleaner and more customizeable than formlib. Thanks! However, what I don't know is how to read/write values of multiple widgets into one context attribute. A common example of this would be a date, which is represented by three TextWidgets (rendered as input fields) that hold the year, month and day, which is stored into one context attribute of type datetime. What would be the best way to accomplish that? The reverse seems to be possible, e.g. a datamanger that splits a widget value into chunks, which are then stored into seperate context attributes, e.g. via a datamanger like context.user, context.host = '[EMAIL PROTECTED]'.split('@'). Best Regards, Hermann -- [EMAIL PROTECTED] GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Zope3 profiler ?
Hi, I'm looking for a simple solution to profile a Zope3 application, some kind of 'ZopeProfiler' product which was available for Zope2. Any link or advise would be welcome... Thanks, Thierry Florac -- Chef de projet intranet/internet Office National des Forêts - Département Informatique 2, Avenue de Saint-Mandé 75570 PARIS Cedex 12 Mél : [EMAIL PROTECTED] Tél. : +33 01.40.19.59.64 Fax. : +33 01.40.19.59.85 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope3 profiler ?
On Tue, Jun 12, 2007 at 06:39:57PM +0200, Thierry Florac wrote: I'm looking for a simple solution to profile a Zope3 application, some kind of 'ZopeProfiler' product which was available for Zope2. That would be a nice thing to have. Any link or advise would be welcome... So far the easiest way I've found is to use my @profile adapter on the view's __call__: from profilehooks import profile class MyViewClass(BrowserView): template = ViewPageTemplateFile('templates/mytemplate.pt') @profile(immediate=True) # if you specify immediate, each request will print the profile to stdout # if you don't, you'll get an aggregate profile when you stop the server def __call__(self): return self.template() You can find profilehooks.py (MIT licence) with some usage examples at http://mg.pov.lt/blog/profiling.html You might also be interested in http://mg.pov.lt/blog/benchmarking-zope3-apps.html Marius Gedminas -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users