Re: [Zope3-Users] z3c.zalchemy - which version to use?
Hi Hermann, Perhaps you've missed this discussion on zope-dev beginning: http://mail.zope.org/pipermail/zope-dev/2008-May/031753.html HTH, Darryl On Thu, 2008-05-08 at 09:24 +0200, Hermann Himmelbauer wrote: Am Mittwoch, 7. Mai 2008 17:43 schrieb Christian Theune: On Wed, May 07, 2008 at 03:41:11PM +0200, Hermann Himmelbauer wrote: Hi, I'd like to know if / which SVN version/branch of z3c.zalchemy works with a current SQLAlchemy distribution. If none does, what about z3c.sqlalchemy? In addition to what Andreas said: zalchemy is going to be abandoned. zope.sqlalchemy will be the common base implementation of transaction integration with SQLAlchemy. Other packages like z3c.sqlalchemy will implement higher level functions in addition to that. Ah, interesting, I was not aware of the existence of zope.sqlalchemy. Thanks to everyone who created the package, this simplifies things a lot. Will the package be contributed with Zope3 itself in the future, as it is in the zope. namespace? I just have a look at it and it looks fairly simple. What I don't understand ist, how/when the Session class should be created: Session = scoped_session(sessionmaker( ... bind=engine, ... twophase=TEST_TWOPHASE, ... transactional=True, autoflush=True, ... extension=ZopeTransactionExtension())) Can I simply put this statement in one of my modules and import the Session class from other modules? This would create the Session class once during Zope startup. Does this mean that I don't need a utility anymore, such as in z3c.zalchemy? Or do I have to create the Session class in each thread, e.g. in my code? Best Regards, Hermann ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Pure python packages for zope.component and zope.interface
On Sun, 2008-04-20 at 12:42 -0400, Jim Fulton wrote: On Apr 20, 2008, at 12:06 AM, Darryl Cousins wrote: ... If I have understood the code correctly in zope.deferredimport the problem which zope.proxy.ProxyBase answers is in the following snippet from z.deferredimport.deferredmodule:initialize [1] where a type(module) comparison is made. Therefore, if I could understand fully Jim's statement: the inspect module's assumption that a module is not a module unless it subclasses the standard Python module type Then I could attempt to substitute pure-python code for the type(module) problem which appears in the `initialize` method. I'm not sure what you mean. The idea is to provide a pure-python implementation of ModuleProxy. ModuleProxy doesn't have to be as complete as zope.proxy allows. The need for a proxy is due to the inspect module's use of isinstance. isinstance in turn uses an object's __class__ attribute, which a proxy can override. Yes, I was off track a little with my last mail. I did get that I need to replace ModuleProxy as you say. I'm trying to figure just what is required of the ModuleProxy class (if not to be as complete as zope.proxy.ProxyBase). I'm not doing very well with understanding _zope_proxy_proxy.c to even figure out what ProxyBase does provide. I hope this hint helps. Well, yes. But I think the task may be beyond my level of understanding. Regards, Darryl Jim -- Jim Fulton Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Pure python packages for zope.component and zope.interface
[Incorrect `from` header in initial] Hello Darryl, I think zope.interface will work without the C stuff, those are just optimizations. Actually it should work with jython already. zope.proxy might not be so simple to get working without C. Thanks. You are right. Silly of me not to try one or the other. If I omit `import zope.component`, `import zope.interface` works without error. Otherwise with zope.component: File /opt/google_appengine/tfws/lib/python2.5/site-packages/zope.proxy-3.4.0-py2.5-linux-i686.egg/zope/proxy/__init__.py, line 20, in module from zope.proxy._zope_proxy_proxy import * ImportError: No module named _zope_proxy_proxy Regards, Darryl (Hopefully) there will be some GSoC projects that will bring the subject and your problem forward: - Porting zope 3 to jython: http://www.gossamer-threads.com/lists/zope/dev/213430 - Zope without ZODB Saturday, April 19, 2008, 1:43:19 AM, you wrote: DC Hi, DC The ZCA framework is developed as part of the Zope 3 project. As noted DC earlier, it is a pure Python framework, so it can be used in any kind of DC Python application. [1] DC I was hoping to try using ZCA for a googleappengine experiment. Using DC Ian Bickings post [2] I set up a environment to install zca packages. DC zope.interface and zope.proxy both have .so files that aren't usable in DC a gae project. (_zope_interface_coptimizations.so and DC _zope_proxy_proxy.so). From the quote above and other mentions on the web I gather that there DC exist pure-python ZCA packages. Could someone point me to where to find DC them? DC Best regards, DC Darryl DC [1] http://www.muthukadan.net/docs/zca.html DC [2] http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/ -- Best regards, Adam GROSZERmailto:[EMAIL PROTECTED] -- Quote of the day: Any fool can criticize, condemn, and complain - and most fools do. - Dale Carnegie ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Pure python packages for zope.component and zope.interface
[incorrect from header in initial] Hi, The ZCA framework is developed as part of the Zope 3 project. As noted earlier, it is a pure Python framework, so it can be used in any kind of Python application. [1] I was hoping to try using ZCA for a googleappengine experiment. Using Ian Bickings post [2] I set up a environment to install zca packages. zope.interface and zope.proxy both have .so files that aren't usable in a gae project. (_zope_interface_coptimizations.so and _zope_proxy_proxy.so). From the quote above and other mentions on the web I gather that there exist pure-python ZCA packages. Could someone point me to where to find them? Doing some *cleverer* googling: https://bugs.launchpad.net/zope3/+bug/204027 Cheers Nicholas, I haven't tried the patch yet but that may get me going with zope.interface. This is a recent post. 2008-03-19. On zope.proxy, I found this: http://article.gmane.org/gmane.comp.web.zope.zope3/13706 Darryl. Best regards, Darryl [1] http://www.muthukadan.net/docs/zca.html [2] http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/ ___ 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] Pure python packages for zope.component and zope.interface
On Sat, 2008-04-19 at 09:30 -0400, Jim Fulton wrote: Here's a high-level response to this thread. As others have pointed out, zope.component and zope.interface should work fine without the C optimizations and I'm in favor of changing the setup to make them installable without the optimizations. zope.proxy is harder. :( What's especially sad is that the dependency on it is rather unimportant. It is used by zope.deferredimport. I was forced to use proxies because of annoying limitations in Python's module implementation and the inspect module's assumption that a module is not a module unless it subclasses the standard Python module type. I expect though that a simpler proxy implementation could be used by deferredimport. This would make zope.component depend on zope.proxy only if the annoying zcml is used. I'd love to see both of the above fixed, but, sadly, don't have time to fix them myself any time soon. Thanks Jim for your comment. Darryl Jim On Apr 18, 2008, at 7:43 PM, Darryl Cousins wrote: Hi, The ZCA framework is developed as part of the Zope 3 project. As noted earlier, it is a pure Python framework, so it can be used in any kind of Python application. [1] I was hoping to try using ZCA for a googleappengine experiment. Using Ian Bickings post [2] I set up a environment to install zca packages. zope.interface and zope.proxy both have .so files that aren't usable in a gae project. (_zope_interface_coptimizations.so and _zope_proxy_proxy.so). From the quote above and other mentions on the web I gather that there exist pure-python ZCA packages. Could someone point me to where to find them? Best regards, Darryl [1] http://www.muthukadan.net/docs/zca.html [2] http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users -- Jim Fulton Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Pure python packages for zope.component and zope.interface
Hi, The ZCA framework is developed as part of the Zope 3 project. As noted earlier, it is a pure Python framework, so it can be used in any kind of Python application. [1] I was hoping to try using ZCA for a googleappengine experiment. Using Ian Bickings post [2] I set up a environment to install zca packages. zope.interface and zope.proxy both have .so files that aren't usable in a gae project. (_zope_interface_coptimizations.so and _zope_proxy_proxy.so). From the quote above and other mentions on the web I gather that there exist pure-python ZCA packages. Could someone point me to where to find them? Best regards, Darryl [1] http://www.muthukadan.net/docs/zca.html [2] http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] sqlalchemy and FieldProperty
On Sun, 2008-01-27 at 13:03 -0500, Stephan Richter wrote: On Friday 21 December 2007, Darryl Cousins wrote: I find that when I map a class to a table I lose the auto-magic vaidation provided by FieldProperty when setting attributes. I bet you that sqlalchemy does some evil class hacking. Actually, I gotta check this out. :-) Yeah, from looking at the mapper.py module, I can see that really weird things happen there. They overwrite attributes left and right. Man, I love persistent! I wish they would have used it as a base for their work. Hi Stephan, Thanks for your comment. Just yesterday I was looking at a couple of external sqlalchemy projects: Elixir [1] and sqlalchemy-validations [2]. I only had a brief look through the code but the way sqlalchemy-validations hooks itself into Elixir seemed point to a way to hook zope fieldproperty in there. Maybe. ;-) [1] http://elixir.ematia.de/trac/ [2] http://code.google.com/p/sqlalchemy-validations/ Regards, Darryl Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Buildout and custom python
Hi, I'm trying to created an isolated environment using buildout. I had understood that defining a custom build python would ensure that all eggs are installed and compiled with the custom python. But when the buildout comes to install ZODB it is being compiled agains the system python headers. (-I/usr/include/python2.4). Which is not what I want, and at that point the custom python has not even been built. Any thoughts. [buildout] python = custom-python parts = python custom-python [python] recipe = zc.recipe.cmmi url = http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tar.bz2 extra_options = --with-threads --with-readline --enable-unicode=ucs2 [custom-python] executable = ${buildout:parts-directory}/python/bin/python ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Buildout and defining build order
Hi, Is it possible to define in which order the parts are built. This relates to my previous post about custom python in the build. If I could ensure the custom python was built first would then eggs be compiled using the custom python? The second case I have is with psycopg2 and postgresql. Their buildout sections look like this: [psycopg2] recipe = zc.recipe.egg:custom egg = psycopg2 find-links = http://www.initd.org/pub/software/psycopg/psycopg2-2.0.6.tar.gz define = PSYCOPG_EXTENSIONS,PSYCOPG_DISPLAY_SIZE,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3 include-dirs = ${postgresql:location}/include library-dirs = ${postgresql:location}/lib rpath = ${postgresql:location}/lib [postgresql] recipe = zc.recipe.cmmi url = ftp://ftp.nz.postgresql.org/postgresql/source/v8.2.5/postgresql-8.2.5.tar.bz2 But psycopg2 gets built first! And so does not find the postgresql headers. Is there a solution to this? Regards, Darryl Cousins ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Buildout and defining build order
Hi Jim, Thank you for the reply. On Thu, 2007-12-20 at 18:23 -0500, Jim Fulton wrote: On Dec 20, 2007, at 6:07 PM, Darryl Cousins wrote: Hi, Is it possible to define in which order the parts are built. Yes, they are built in the order listed. You must mean the order the sections are listed and not the order listed in parts. I've tried playing with both orderings but when I start the buildout it first runs through the develop eggs then starts on with ZODB - and the custom python is not built. This relates to my previous post about custom python in the build. If I could ensure the custom python was built first would then eggs be compiled using the custom python? Well, yes, sort of. I suspect the following thread is relevent: http://mail.python.org/pipermail/distutils-sig/2007-November/008482.html Yes this or a similar post was my starting point some months back. I seemed to be all good but recently someone else has tested it and has run into the 2 problems mentioned. 1. Eggs (eg ZODB) are byte-comiled with system python. 2. Couldn't get postgresql to build first so that psycopg2 finds those header It's hard to say because your just showing snippets of your buildout. I've attached buildout.cfg and dependencies.cfg (version.cfg) is a copy of KGS. Thank you for your time. Darryl [buildout] find-links = http://download.zope.org/zope3.4 http://download.zope.org/distribution download-cache = var/cache eggs-directory = var/eggs develop-eggs-directory = var/develop-eggs python = python log-level = DEBUG versions = versions newest = false extends = dependencies.cfg versions.cfg parts = python interpreter postgresql httpd htdocsdir apache app test ramdb egenix-mx-base psycopg2 pyxml mailqueue coverage i18n develop = . vortex.recipe.filetemplate vortex.recipe.mailqueue vortex.recipe.ramdb vortex.recipe.setup_install psycopg2da sqlos z3c.zalchemy [app] recipe = zc.recipe.egg eggs = ${interpreter:eggs} zope.app.apidoc zope.app.securitypolicy z3c.evalexception=2.0 Paste PasteScript PasteDeploy [versions] pysqlite = 2.4.0 [mailqueue] recipe = vortex.recipe.mailqueue [coverage] recipe = zc.recipe.egg eggs = z3c.coverage [i18n] recipe = lovely.recipe:i18n package = vortex domain = vortex location = vortex output = locales [test] recipe = zc.recipe.testrunner eggs = vortex.recipe.filetemplate vortex.recipe.mailqueue vortex.recipe.ramdb vortex.recipe.setup_install psycopg2 sqlos z3c.zalchemy defaults = ['--tests-pattern', '^f?tests$', '-v' ] [buildout] index = http://download.zope.org/ppix [python] recipe = zc.recipe.cmmi url = http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tar.bz2 extra_options = --with-threads --with-readline --enable-unicode=ucs2 executable = ${buildout:parts-directory}/python/bin/python [interpreter] recipe = zc.recipe.egg eggs = ${test:eggs} setuptools psycopg2 SQLObject sqlos lxml SQLAlchemy Pyro psycopg2da zif.jsonserver python-cjson interpreter = python [egenix-mx-base] recipe = vortex.recipe.setup_install url = http://downloads.egenix.com/python/egenix-mx-base-3.0.0.tar.gz python = python package = mx [postgresql] recipe = zc.recipe.cmmi url = ftp://ftp.nz.postgresql.org/postgresql/source/v8.2.5/postgresql-8.2.5.tar.bz2 [psycopg2] recipe = zc.recipe.egg:custom egg = psycopg2 find-links = http://www.initd.org/pub/software/psycopg/psycopg2-2.0.6.tar.gz define = PSYCOPG_EXTENSIONS,PSYCOPG_DISPLAY_SIZE,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3 include-dirs = ${postgresql:location}/include library-dirs = ${postgresql:location}/lib rpath = ${postgresql:location}/lib [pyxml] recipe = vortex.recipe.setup_install url = http://optusnet.dl.sourceforge.net/sourceforge/pyxml/PyXML-0.8.4.tar.gz python = python package = _xmlplus [httpd] recipe = tl.buildout_apache:httpd url = http://apache.tradebit.com/pub/httpd/httpd-2.2.6.tar.bz2 md5sum = 203bea91715064f0c787f6499d33a377 extra-options = --enable-rewrite=shared [apache] recipe = tl.buildout_apache:root user = daemon group = daemon listen = 127.0.0.1:8081 modules = authz_host rewrite servername = localhost:8081 htdocs = ${buildout:directory}/var/htdocs [htdocsdir] recipe = lovely.recipe:mkdir path = ${apache:htdocs} ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Buildout and custom python
Hi David, I've tried out the methods described here: http://mail.python.org/pipermail/distutils-sig/2007-November/008489.html and have plumped for the buildout.sh shell script which builds python and then uses that to bootstrap and re-continue the buildout. It is working well and I see that all eggs are then compiled with the compiled python. I had already begun using a Makefile to build/test/run the project so I find it convenient to use a shell script in the mix. Regards, Darryl On Thu, 2007-12-20 at 21:03 -0400, David Pratt wrote: Hey Darryl. Our minds were in a similar place today. I finally had decided to move away from my system python starting on my mac and also having a spot of trouble. I put something simple together below to illustrate what happened in my instance. Here the eggs built with the python would not install. I initially though it was the lxml I was compiling, but it was just happened to be the first part requiring the custom-python. Eggs were made, and I could see the temp folder also, but when was finalizing the install, it threw the error and without much verbosity, the tempfolder it was installing into disappeared. Note, I did not include the custom-python as a part in the buildout. I tend to like the python24:location type of notation since it is fairly explicit when you have a number of pieces of software you are building. Regards David [buildout] develop = . parts = python24 interpreter index = http://download.zope.org/ppix log-level = DEBUG [python24] recipe = zc.recipe:cmmi url = http://python.org/ftp/python/2.4.4/Python-2.4.4.tgz [custom-python] executable = ${python24:location}/bin/python [interpreter] recipe = zc.recipe.egg interpreter = interpreter eggs = Cheetah==1.0 python = custom-python Here are the highlights: Some verification it is using the right python... Getting distribution for 'Cheetah==1.0'. We have the best distribution that satisfies 'setuptools'. Picked: setuptools = 0.6c7 Running easy_install: /Users/davidpratt/Desktop/Buildouts/osxdeploy2/parts/python24/bin/python -c from setuptools.command.easy_install import main; main() -mUNxd /Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/tmprQq-MH -v /Users/davidpratt/Desktop/Buildouts/download-cache/dist/Cheetah-1.0.tar.gz path=/Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/setuptools-0.6c7-py2.4.egg Processing Cheetah-1.0.tar.gz Last few lines of output.. some time later. changing mode of /Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/tmprQq-MH/Cheetah-1.0-py2.4-macosx-10.3-ppc.egg/EGG-INFO/top_level.txt to 755 changing mode of /Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/tmprQq-MH/Cheetah-1.0-py2.4-macosx-10.3-ppc.egg/EGG-INFO/scripts/cheetah to 755 changing mode of /Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/tmprQq-MH/Cheetah-1.0-py2.4-macosx-10.3-ppc.egg/EGG-INFO/scripts/cheetah-compile to 755 Installed /Users/davidpratt/Desktop/Buildouts/osxdeploy2/eggs/tmprQq-MH/Cheetah-1.0-py2.4-macosx-10.3-ppc.egg Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require(Cheetah) # latest installed version pkg_resources.require(Cheetah==1.0) # this exact version pkg_resources.require(Cheetah=1.0) # this version or higher Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) While: Installing interpreter. Getting distribution for 'Cheetah==1.0'. Error: Couldn't install: Cheetah 1.0 [mac-pg:~/Desktop/Buildouts/osxdeploy2] davidpra% Jim Fulton wrote: On Dec 20, 2007, at 6:03 PM, Darryl Cousins wrote: I'm trying to created an isolated environment using buildout. I had understood that defining a custom build python would ensure that all eggs are installed and compiled with the custom python. But when the buildout comes to install ZODB it is being compiled agains the system python headers. (-I/usr/include/python2.4). Which is not what I want, and at that point the custom python has not even been built. Any thoughts. [buildout] python = custom-python parts = python custom-python [python] recipe = zc.recipe.cmmi url = http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tar.bz2 extra_options = --with-threads --with-readline --enable-unicode=ucs2 [custom-python] executable = ${buildout:parts-directory}/python/bin/python Your buildout doesn't mention ZODB3 or anything that uses it, so it is hard to comment. Jim -- Jim Fulton Zope
Re: [Zope3-Users] Re: Buildout and defining build order
Hi On Fri, 2007-12-21 at 01:25 +0100, Martin Aspeli wrote: Darryl Cousins wrote: Hi Jim, Thank you for the reply. On Thu, 2007-12-20 at 18:23 -0500, Jim Fulton wrote: On Dec 20, 2007, at 6:07 PM, Darryl Cousins wrote: Hi, Is it possible to define in which order the parts are built. Yes, they are built in the order listed. You must mean the order the sections are listed and not the order listed in parts. I've tried playing with both orderings but when I start the buildout it first runs through the develop eggs then starts on with ZODB - and the custom python is not built. I'm pretty sure it runs in the order in the 'parts' variable inside the main [buildout] section - at least all my testing has indicated this is the case. Can you create a minimal test buildout that demonstrates different behaviour? On the contrary, my experiment shows that you are correct. I have found though the solution to the postgresql/psycopg2 problem. And further I'm using SchoolTools method to pre-build the python to use to bootstrap and run the buildout. Thanks for you help all. Regards, Darryl Martin ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] sqlalchemy and FieldProperty
Hi, I find that when I map a class to a table I lose the auto-magic vaidation provided by FieldProperty when setting attributes. class IMyObject(zope.interface.Interface): now = zope.schema.Datatime() class MyObject(object): zope.interface.implements(IMyOBject) now = zope.schema.fieldproperty(IMyObject['now']) object_table = sqlalchemy.Table( 'object_table', z3c.zalchemy.metadata(), sqlalchemy.Column('now', sqlalchemy.DateTime)) sqlalchemy.orm.mapper(MyObject, object_table) obj = MyObject() obj.now = u'Not a date time object' If I simply remove the mapper defintion obj = MyObject() obj.now = u'Not a date time object' WrongType: (u'Not a date time object', type 'datetime.datetime') Has anyone found a work around? Because I would like to have data validated without having to write code to do so. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] formlib vs z3c.form
Hi, On Fri, 2007-12-07 at 06:09 +0800, Adam Summers wrote: Hi, A quick, blind question. I've been evaluating grok and am very impressed at how easy it makes the whole development process. How hard is it to get grok to play nicely with z3c.form et al? Has anyone any examples? Some months ago I worked on this. Unfortunately I haven't kept up with recent updates to Grok so the code will be broken. My way to deal with incorporating z3c patterns into Grok is with a set of grokkers which I packaged in the mars.* namespace. I had also duplicated the z3c.formdemo as mars.formdemo. I began pulling it all together in a simple website application: tfws.website. This code is here: http://svn.zope.org/Sandbox/darrylcousins/ Best regards, Darryl Thanks and Regards, Adam Christophe Combelles wrote: Chris Withers a écrit : Chris Withers wrote: I need something like formlib so want to give it a spin. Is there a good how-to or example anywhere? Kapil rightly pointed out off-list that z3c.form is the latest and greatest. Which one is best and where do I go for docs/examples? The main doc is the doctest, you can read it just here: http://pypi.python.org/pypi/z3c.form The second doc is the code of z3c.formdemo. http://pypi.python.org/pypi/z3c.formdemo you will also find some interesting informations here: http://pcardune.blogspot.com/2007/05/using-z3c-pagelettemplatelayout.html http://www.lovelysystems.com/srichter/2006/09/20/the-skin-browser-and-lovely-systems-new-development-workflow/ But the most interesting source of information is the archive of this list. It's best if you have it localy, otherwise: http://www.mail-archive.com/search?q=z3c.forml=zope3-users%40zope.org If you carefully read all the previous questions asked about z3c.form on the list, you will first save an afternoon discovering why you need to derive IFormLayer in your skin, then another afternoon discovering how to implement an Add SubForm, and probably many others :) I personnally suggest you to try z3c.form alone first, without any other z3c package. It will progressively help you understand why others are extremely useful (though not mandatory), such as z3c.formui, z3c.layer, and others. Christophe cheers, Chris ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Browsing zope3 interfaces
On Fri, 2007-11-30 at 14:00 -0800, Roman Budzianowski wrote: Please bear with me - I am still trying to get a handle on zope 3 in my spare time. What's the best way to discover zope functionality? I am using http://apidoc.zope.org/++apidoc++/Code/zope/. However, when in Web Component... book I ran into 'canAccess' and 'canWrite' methods I couldn't find them in the apidoc. Is there a searchable interface browser? I don't know. I frequently use `grep` on my egg directory. And google (TM) can be useful with the `site` parameter, type: canWrite site:apidoc.zope.org/++apidoc++/ in the search field of google. The links are out of the frames but at least you see where to go to get an answer. HTH. Darryl Thanks, Roman [EMAIL PROTECTED] ___ 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
[Zope3-Users] Configuring a package to use a file in buildout
Hi, I have a custom logger in a package registered with utility zope:utility factory=.logger.MyLogger name=logger / In the code it sets itself a logfile to write to, up to now that has been in a 'log' directory in the package itself. Now I want to use a log file which is in the buildout of the application. How could I go about finding that directory from python code in the package? The only route that I have come up with so far is to write a meta:directive which I can use to register the logging utility with a file path. Something like: meta:directive namespace=http://namespaces.zope.org/rdb; name=provideLogger schema=.zcml.IProvideLoggerDirective handler=.zcml.loggerhandler / Which I could use like provideLogger component=.logger.MyLogger log=/path/to/log/file / But there may be a better/easier way. Suggestions? Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Configuring a package to use a file in buildout
Hi Jürgen, Thanks! I'll try that out. Darryl On Fri, 2007-11-23 at 11:00 +0100, Jürgen Kartnaller wrote: In your buildout you do : [instance] recipe = zc.zope3recipes:instance application = app address = 8080 zope.conf = product-config my-config-name storagedir ${buildout:directory}/parts/log /product-config If you need the log dir precreated you do : [extfiledir] recipe = lovely.recipe:mkdir path = parts/log To access the product config from python : from zope.app.appsetup.product import getProductConfiguration config = getProductConfiguration('my-config-name') if config is not None: path = config.get('logpath') Use your utility name as my-config-name. Jürgen Darryl Cousins wrote: Hi, I have a custom logger in a package registered with utility zope:utility factory=.logger.MyLogger name=logger / In the code it sets itself a logfile to write to, up to now that has been in a 'log' directory in the package itself. Now I want to use a log file which is in the buildout of the application. How could I go about finding that directory from python code in the package? The only route that I have come up with so far is to write a meta:directive which I can use to register the logging utility with a file path. Something like: meta:directive namespace=http://namespaces.zope.org/rdb; name=provideLogger schema=.zcml.IProvideLoggerDirective handler=.zcml.loggerhandler / Which I could use like provideLogger component=.logger.MyLogger log=/path/to/log/file / But there may be a better/easier way. Suggestions? Regards, Darryl ___ 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] Eggs and classic instance homes, again... (was Re: Eggs, workingenv.py, and 'classic' instance homes)
On Wed, 2007-11-07 at 21:22 -0700, Jeff Shell wrote: On Nov 7, 2007 7:53 PM, Darryl Cousins [EMAIL PROTECTED] wrote: Hi Jeff, I hope that this might at least give you the optimism you appear to be lacking. Thank you. That does give me a much more clear starting point. I was having a hard time seeing all of the recipes come together. Cheers Jeff. A note about pinning down the versions, I'm following this: http://mail.zope.org/pipermail/zope3-users/2007-November/007106.html now rather than using the grok versions. I didn't have any trouble at all resolving deprecation and import errors when upgrading from Zope3.3.0 tarball to the 3.4 eggs as described in the above mail. There were hardly any compared with the upgrade from 3.2.0 to 3.3.0. Application is up and running on eggs. Brrroook. Regards, Darryl As for optimism... We'll see. :) But this was the step I could never make work (getting a buildout-managed instance up and running) before running out of time. Thanks again. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Duplicate emails from mail queue
On Mon, 2007-11-05 at 17:20 +1300, Darryl Cousins wrote: Hi, On Sun, 2007-11-04 at 22:41 -0500, Benji York wrote: Darryl Cousins wrote: Has anyone experienced duplicate emails being sent using IQueuedMailDelivery? We've seen this when you have more than one process (or thread) attempting to deliver messages from a single maildir. I've recently made changes on the zope.sendmail trunk to eliminate the duplicates. I need to do another release, maybe tomorrow. If you want to try the fix before a release is made, you can try running a trunk checkout. Thanks Benji. I don't have time to try the trunk today, will keep an eye out for the new release. Hi Benji, Initial tests seem to show that the problem is solved using the trunk. Regards, Darryl Best regards, Darryl ___ 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] Eggs and classic instance homes, again... (was Re: Eggs, workingenv.py, and 'classic' instance homes)
Hi Jeff, I hope that this might at least give you the optimism you appear to be lacking. I've been migrating a complex project which was running on Zope-3.2 tarball install. My first step was to get it all into a buildout. buildout.cfg looked something like this [1]. I've missed out lots here (postgresql, lxml, sqlos, sqlobject, psycopg2, pyro, zif.jsonserver amongst others). Note that I have included a local install of python in parts to keep things clean and tidy. Second step was to upgrade to Zope-3.3 - this just meant changing the url in the zope3 section. An hour or two of fixing deprecation warnings (really only deprecation stuff, nothing major). Step Three, where I'm at now, is to change the buildout to use Zope-3.4 eggs, and Paste. Zopeproject buildout.cfg and other files could provide you a starting point. I'm using http://grok.zope.org/releaseinfo/grok-0.10.2.cfg to pin down versions. See http://grok.zope.org/releaseinfo/readme.html for info on using this file. I haven't got the server running yet, but then I've only just finished getting buildout.cfg right, and all parts built. In all there has been several hours work so far, but that includes sorting out the additional dependencies (postgresql etc). Before the buildout the whole application was a nightmare to install. Now its looking sooo much better. I would skip step two if I did this again, although I imagine there will be a lot more import and deprecation errors to correct. Hope that helps. Regards, Darryl [1] buildout.cfg [buildout] index = http://download.zope.org/ppix develop = . parts = zope3 server instance database test projectpackage # the application code find-links = http://download.zope.org/distribution/ download-cache = cache eggs-directory = eggs # keeping this install fully separate from others develop-eggs-directory = develop-eggs [zope3] recipe = zc.recipe.cmmi url = http://www.zope.org/Products/Zope3/3.2.0/Zope-3.2.0.tgz extra_options = --with-python=${python:location}/bin/python --force [server] recipe = zc.recipe.egg eggs = ${projectpackage:eggs} [instance] recipe = zc.zope3recipes:instance application = projectpackage zope.conf = ${database:zconfig} [database] recipe = zc.recipe.filestorage [test] recipe = zc.recipe.testrunner eggs = ${projectpackage:eggs} extra-paths = ${zope3:location}/lib/python working-directory = ${buildout:directory}/test defaults = ['--tests-pattern', '^f?tests$', '-v' ] [projectpackage] recipe = zc.zope3recipes:app eggs = ${interpreter:eggs} site.zcml = include package=projectpacakge / # all zcml defined here [python] recipe = zc.recipe.cmmi url = http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tar.bz2 executable = ${buildout:parts-directory}/python/bin/python extra_options = --with-threads --with-readline --enable-unicode=ucs2 [interpreter] recipe = zc.recipe.egg eggs = setuptools # list-of-eggs: lxml, sqlos etc, etc interpreter = python extra-paths = ${buildout:parts-directory}/zope3/lib/python On Wed, 2007-11-07 at 17:24 -0700, Jeff Shell wrote: The last time I was active on this list was back in mid-august. I was fighting an uphill battle to try to figure out how to migrate our software to 'Eggs'. I ultimately had to abandon the process as there was just too much real work to be done, and I was getting conflicting answers about how to move forward. Actually, I couldn't get much help from the community at all. I apologize for the crankiness of this email. The last time I tried to get help on this topic was an excercise in sheer frustration. Since then, the gulf I've worried about seems to have gotten even bigger, and I'm feeling very stressed right now. So now I see all that's going on with Zope 3 and I still don't understand a thing about how to move forward. We have about twelve active customers deployed on Zope 3, on top of one or two large frameworks that we've built on top if Z3. We still use the basic 'instance home' layout. We don't use eggs - we just check things out directly into the instance home. Even stuff from the Zope community, because it's easier to do that than to even get workingenv or any of these other things running. I'm still lost about what to do. Grok is of no use to us at the moment. Many of these apps have been up and running for longer than Grok's been alive. Is there any kind of migration documentation out there? Or have these new ways of doing things been in use for so long that most people have just rolled along with them? I just don't have the time. I scarcely have time to keep up with the lists (which is obvious since I haven't read a thing for nearly three months). I'm going to resume my conversation here, responding to myself. August 16, 2007, Jeff Shell wrote: Jeff Shell wrote: But now I'd like to be able to install that into classic zope 3.3 instance homes, trying to be as
[Zope3-Users] Duplicate emails from mail queue
Hi, Has anyone experienced duplicate emails being sent using IQueuedMailDelivery? In zope log it appears to be sent only once: 2007-10-30T07:13:03 INFO QueueProcessorThread Mail ... but 2 emails are received. Any clues on where to look and how to correct the problem? Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Duplicate emails from mail queue
Hi, On Sun, 2007-11-04 at 22:41 -0500, Benji York wrote: Darryl Cousins wrote: Has anyone experienced duplicate emails being sent using IQueuedMailDelivery? We've seen this when you have more than one process (or thread) attempting to deliver messages from a single maildir. I've recently made changes on the zope.sendmail trunk to eliminate the duplicates. I need to do another release, maybe tomorrow. If you want to try the fix before a release is made, you can try running a trunk checkout. Thanks Benji. I don't have time to try the trunk today, will keep an eye out for the new release. Best regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form, checkboxes for Bool fields
Hi, On Tue, 2007-09-04 at 18:35 -0400, Stephan Richter wrote: On Saturday 01 September 2007 19:36, Andreas Reuleaux wrote: Is there a way to have only one checkbox generated? - like this: [ ] Invitation That's what I want. I have implemented this widget now. It is available in the z3c.form trunk and I updated the All widgets demo as well showing the new widget. Thanks Stephan. Regards, Darryl Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Creating edit form with z3c.form
Hey Hermann, On Sun, 2007-08-19 at 00:45 +0200, Hermann Himmelbauer wrote: raise ComponentLookupError(objects, interface, name) ComponentLookupError: ((zope.app.publisher.browser.viewmeta.EditEntry object at 0x9f6c68c, zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/Blog/2007_08_16_abc/EditEntry.html, Blog.blog.BlogEntry object at 0x9264d2c), InterfaceClass z3c.form.interfaces.IWidgets, u'') This tells us that we are looking for a multi-adapter to view, request and context that adapts IWidgets (Have I got that right?). Florian was on the right track to ask about the layer and pagelet but you might be missing a configure / include where an adapter for IWidgets is registered. Hope that helps, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Invariants and forms
Hi, This was answered recently me thinks. http://mail.zope.org/pipermail/zope3-users/2007-August/006648.html Regards, Darryl On Mon, 2007-08-13 at 11:37 +0200, [EMAIL PROTECTED] wrote: Hello, I'm using an invariant to check if given passwords are equal. I've found two different examples(see below), but both don't display my given exception message. The only thing i get is the standard error message. Since this is my first experience with zope, could someone explain to me the correct way to get a custom error message with invariants? Thanks!!! I'm using zope version 3.3.1. First example (taken from: http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-in-interfaces-mit-zope-formlib/): class PasswordsAreNotEqual(zope.schema.ValidationError): uDas Passwort und die Wiederholung sind nicht gleich. zope.interface.implements(zope.app.form.interfaces.IWidgetInputError) def arePasswordsEqual(obj) if obj.password != obj.password2: raise PasswordsAreNotEqual from zope.interface import Interface, invariant class IUser(Interface): password = zope.schema.Password(title=uPasswort) password2 = zope.schema.Password(title=uWiederholung des Passworts) arePasswordsEqual = invariant(arePasswordsEqual) Second example (taken from: http://blog.gocept.com/zope3-testen-von-felderuebergreifenden-bedingungen-invariants-in-interfaces-mit-zope-formlib-aktualisiert) import zope.interface class IUser(zope.interface.Interface): password = zope.schema.Password(title=uPasswort) password2 = zope.schema.Password(title=uWiederholung des Passworts) @zope.interface.invariant def arePasswordsEqual(user): if user.password != user.password2: raise zope.interface.Invalid( uDas Passwort und die Wiederholung sind nicht gleich.) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.form, applyChanges, IModifiedEvent
Hi, Following a post on grok-dev I learnt about additional arguments to ModifiedEvent. http://mail.zope.org/pipermail/grok-dev/2007-August/001807.html By changing z3c.form.form.applyChanges to return a dictionary of interfaces and names of the attributes changed (instead of the current bool value) then I can easily create the correct additional attributes within the applyChanges method of EditForm: def applyChanges(form, content, data): changes = {} for name, field in form.fields.items(): # If the field is not in the data, then go on to the next one if name not in data: continue # Get the datamanager and get the original value dm = zope.component.getMultiAdapter( (content, field.field), IDataManager) oldValue = dm.get() # Only update the data, if it is different if dm.get() != data[name]: dm.set(data[name]) # get the interface and collect changed attribute names changes.setdefault(dm.field.interface, []).append(name) return changes class EditForm(Form): def applyChanges(self, data): content = self.getContent() changes = applyChanges(self, content, data) if changes: # testing a dict as a bool is prone to error??? descriptions = [] for interface, names in changes.items(): descriptions.append(zope.lifecycleevent.Attributes(interface, *names)) zope.event.notify( zope.lifecycleevent.ObjectModifiedEvent(content, *descriptions)) return changes Hopefully pypi will be back up again later today so I can do a fresh build of z3c.form and run the tests with my changes as set out above. Best regards, Darryl Cousins ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.formdemo, problems with lxml
Hi Andreas, On Thu, 2007-08-09 at 10:12 +0200, Andreas Reuleaux wrote: I am just following the very simple instructions to install z3c.formdemo from zc.buildout snip On Debian this may work: apt-get libxml2-dev libxslt-dev Hope that helps. Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: [Zope3-dev] z3c.formjs-0.2 and z3c.formjsdemo-0.2 released!
Hi Paul, Hey, very smooth. Congratulations. I've committed a change to buildout.cfg removing z3c.form* develop eggs which kinda spoilt the buildout. Best regards, Darryl Cousins ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Building an admin interface
Hi, On Tue, 2007-07-17 at 08:45 +0200, Hermann Himmelbauer wrote: Am Montag, 16. Juli 2007 22:44 schrieb Stephan Richter: On Monday 16 July 2007 15:58, Benji York wrote: This reminds me of something I've been curious about but haven't had time to research lately. What are the differences between pagelets and viewlets and their various strengths/weaknesses. An acceptable answer is read the docs and decide for yourself. wink snip That leads me to the question if it's possible to mix pagelets/viewlets? In my case, I have one main content area but I have some dynamic code, e.g. a navigation box, a login box, later perhaps a search box etc. How would I implement them? Perhaps I use a viewlet manager / viewlet in the layout template? I recommend reading the README's of z3c.template and z3c.pagelet (and z3c.macro for good measure). Also study of z3c.formdemo teaches much about the patterns developed in the z3c packages. But I think I can answer your question. 1. Register a layout template to your layer using z3c:layout (see z3c.formdemo/skin for an example) 2. It could contain: tal:block replace=structure provider:leftcol /!--dynamic code -- tal:block replace=structure provider:pagelet /!-- content area -- tal:block replace=structure provider:rightcol /!--dynamic code -- 3. left and right columns are your own viewlet managers registered with browser:viewletManager 4. `pagelet` is special, you can register a view using z3c:pagelet (and a template for it with z3c:template) and the `pagelet` provider will do the rest. This pattern is used in z3c.formdemo. Hope this helps. Regards, Darryl Best Regards, Hermann ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form 1.4.0, z3c.formui 1.1.0, and z3c.formdemo 1.2.0 released!
Hi, On Wed, 2007-07-04 at 16:27 -0400, Stephan Richter wrote: snip The questionnaire returned with errors (because groups return RequiredMissing errors). Should fields be selected to name and age only? If not, then is there a template registration missing perhaps for the fieldsets? Does this problem still persist? I have worked with the packages the last days and everything seems to work just fine. And it certainly does. Cheers. Amazing. It sent me diving into jquery packages. You all have provided a wonderful set of tools. Thank you. Thank you. Very cool! I think the jquery stuff is very nice and coming along well. Paul will be working on form validation the next days, so stay tuned! This jquery plugin came to my attention, perhaps you are already aware of it? http://malsup.com/jquery/taconite/ Best regards, DArryl Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form 1.4.0, z3c.formui 1.1.0, and z3c.formdemo 1.2.0 released!
Hi, On Fri, 2007-06-29 at 03:50 -0400, Stephan Richter wrote: Hello everyone, again thanks to the great feedback we received -- especially from David Pratt, Roy Mathew, and Joachim Werner -- we were able to fine-tune our new form framework even more to make it as robust of a foundation as possible for your projects! New features include group support, fully internationalized widgets for number and calendar fields, a richer select widget, refined form templates, and of course a new demo! BTW, congratulations to Roger who became father for the third time last weekend! Sincere congratulations indeed! Again for the curious and impatient ... --- There is also a new demo, of course! The Questionnaire demo provides a form for filling out a simple questionaire about someones Zope community involvement and then provides a very simple results page. Technically this demo (available for the DIV- and Table-based layouts) demonstrates the usage of groups, a new feature of this release, as well as writing attribute value adapters. The questionnaire returned with errors (because groups return RequiredMissing errors). Should fields be selected to name and age only? If not, then is there a template registration missing perhaps for the fieldsets? ... Paul has made some great progress recently and we have now two demos working, including a fully Javascript-driven calculator. I'll leave it up to Paul to decide whether he wants to make an announcement, but he will be definitely promoting his work at EuroPython! secretTo see the demos: Replace formdemo with formjsdemo and follow the instructions above./secret Amazing. It sent me diving into jquery packages. You all have provided a wonderful set of tools. Thank you. Thank you. Regards, Darryl Changes --- z3c.form - Feature: The select widget grew a new ``prompt`` flag, which allows you to explicitely request a selection prompt as the first option in the selection (even for required fields). When set, the prompt message is shown. Such a prompt as option is common in Web-UIs. - Feature: Allow no value message of select widgets to be dynamically changed using an attribute value adapter. - Feature: Internationalized data conversion for date, time, date/time, integer, float and decimal. Now the locale data is used to format and parse those data types to provide the bridge to text-based widgets. While those features require the latest zope.i18n package, backward compatibility is provided. - Feature: All forms now have an optional label that can be used by the UI. - Feature: Implemented groups within forms. Groups allow you to combine a set of fields/widgets into a logical unit. They were designed with ease of use in mind. - Feature: Button Actions -- in other words, the widget for the button field -- can now be specified either as the actionFactory on the button field or as an adapter. - Bug: Recorded all public select-widget attributes in the interface. z3c.formui ~~ - Feature: Registered all defined macros for each form template. Also, added more slots to the templates providing more hooks for customization. - Feature: Added a macro/slot for the required info, which explains how required fields are marked. - Feature: Added support for form labels. - Feature: Added support for groups to templates. z3c.formdemo - Feature: Added new field promptChoiceField to the All Widgets demo demonstrating the prompt message of the select widget. - Feature: Increased the integer default value of All Widgets demo to show off our new internationalized converter. - Feature: Made ``bytesField`` and ``passwordField`` non-required, since they do not show their default values prohibiting the form to successfully submit, which can be annoying when playing around. - Feature: New Questionnaire demo shows how to use groups effectively. It also demonstrates how the label of buttons and widgets can be changed using attribute value adapters. Enjoy! Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form 1.4.0, z3c.formui 1.1.0, and z3c.formdemo 1.2.0 released!
Hi, On Fri, 2007-06-29 at 12:03 +0200, Martin Hefler wrote: Hi, I had the same problem, when I was updating version 1.3.0 to 1.4.0. After checking out to a new directory it works fine. Yep, right you are. Regards, Darryl Regards Martin Am 29.06.2007 um 11:43 schrieb Darryl Cousins: Hi, On Fri, 2007-06-29 at 03:50 -0400, Stephan Richter wrote: Hello everyone, again thanks to the great feedback we received -- especially from David Pratt, Roy Mathew, and Joachim Werner -- we were able to fine-tune our new form framework even more to make it as robust of a foundation as possible for your projects! New features include group support, fully internationalized widgets for number and calendar fields, a richer select widget, refined form templates, and of course a new demo! BTW, congratulations to Roger who became father for the third time last weekend! Sincere congratulations indeed! Again for the curious and impatient ... --- There is also a new demo, of course! The Questionnaire demo provides a form for filling out a simple questionaire about someones Zope community involvement and then provides a very simple results page. Technically this demo (available for the DIV- and Table-based layouts) demonstrates the usage of groups, a new feature of this release, as well as writing attribute value adapters. The questionnaire returned with errors (because groups return RequiredMissing errors). Should fields be selected to name and age only? If not, then is there a template registration missing perhaps for the fieldsets? ... Paul has made some great progress recently and we have now two demos working, including a fully Javascript-driven calculator. I'll leave it up to Paul to decide whether he wants to make an announcement, but he will be definitely promoting his work at EuroPython! secretTo see the demos: Replace formdemo with formjsdemo and follow the instructions above./secret Amazing. It sent me diving into jquery packages. You all have provided a wonderful set of tools. Thank you. Thank you. Regards, Darryl Changes --- z3c.form - Feature: The select widget grew a new ``prompt`` flag, which allows you to explicitely request a selection prompt as the first option in the selection (even for required fields). When set, the prompt message is shown. Such a prompt as option is common in Web-UIs. - Feature: Allow no value message of select widgets to be dynamically changed using an attribute value adapter. - Feature: Internationalized data conversion for date, time, date/ time, integer, float and decimal. Now the locale data is used to format and parse those data types to provide the bridge to text-based widgets. While those features require the latest zope.i18n package, backward compatibility is provided. - Feature: All forms now have an optional label that can be used by the UI. - Feature: Implemented groups within forms. Groups allow you to combine a set of fields/widgets into a logical unit. They were designed with ease of use in mind. - Feature: Button Actions -- in other words, the widget for the button field -- can now be specified either as the actionFactory on the button field or as an adapter. - Bug: Recorded all public select-widget attributes in the interface. z3c.formui ~~ - Feature: Registered all defined macros for each form template. Also, added more slots to the templates providing more hooks for customization. - Feature: Added a macro/slot for the required info, which explains how required fields are marked. - Feature: Added support for form labels. - Feature: Added support for groups to templates. z3c.formdemo - Feature: Added new field promptChoiceField to the All Widgets demo demonstrating the prompt message of the select widget. - Feature: Increased the integer default value of All Widgets demo to show off our new internationalized converter. - Feature: Made ``bytesField`` and ``passwordField`` non-required, since they do not show their default values prohibiting the form to successfully submit, which can be annoying when playing around. - Feature: New Questionnaire demo shows how to use groups effectively. It also demonstrates how the label of buttons and widgets can be changed using attribute value adapters. Enjoy! Regards, Stephan ___ 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
Re: [Zope3-Users] z3c.form 1.0.0 released!
Hi Vinny, On Sun, 2007-05-27 at 18:55 -0400, Vinny wrote: For the curious and impatient ... - To run the demos do the following:: $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/trunk formdemo $ cd formdemo $ python bootstrap.py $ ./bin/buildout $ ./bin/demo fg I did try the above, but it complained about needing a newer setuptools than I had. No big deal, I can update that easily enough. Before I go further though, does the above command set install a full version of zope and if so, what version? Do I need 3.4.0a1 to run this demo or can I use 3.3.0 or 3.3.1? I'm running 3.3.0 but can upgrade to 3.3.1. Some tips with buildout that work for me. Create ~/.buildout/default.cfg:: [buildout] eggs-directory=/path/to/eggs develop-eggs-directory=/path/to/develop-eggs #optional Of course choose your own egg directories. Then run the buildout as in original post. This will take an awfully long time. The next time you install another zope 3 app from buildout, it will use the same eggs directory:: ./bin/buildout -N The -N means that it won't look for newer eggs if the local egg satisfies requirements. And it will take no time at all. As to the version - I have no idea how that works with the egg distribution of separate packages. Hope this helps. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form 1.0.0 released!
Hi, Congratulations Stephan and Roger. I've only read through 3 of the 5 'must read' doctest files. I remember my first reading of formlib/form.txt and being overwhelmed. This has been the opposite experience. The demos are impressive, to say the least. There is much by way of example in the writing of your doctests. Thanks for this effort. Regards, Darryl On Thu, 2007-05-24 at 12:01 -0400, Stephan Richter wrote: Hello everyone, Roger and I are proud to announce the first release of the new form and widget framework ``z3c.form``! After years of talking about it, months of thinking about it and many weeks of implementation, we have finally completed it. For the curious and impatient ... - To run the demos do the following:: $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/trunk formdemo $ cd formdemo $ python bootstrap.py $ ./bin/buildout $ ./bin/demo fg Now you can access the demo under: http://localhost:8080/ Since this takes a while to build, you can read on while waiting for the demo to come up. :-) Goals of z3c.form - While taking the best of the older ``zope.app.form`` and ``zope.formlib`` packages, this new framework provides much more flexibility and hooks as are needed in daily development. For example, creating a simple form can look almost identical to ``zope.formlib``, but integrating sub-forms is much simpler. Another important issue for us was keeping up-to-date with today's latest Web developments, especially AJAX-features. It is an expressed goal of this framework to provide enough flexibility to fully support AJAX-driven forms and widgets. A secondary goal is to provide flexibility to allow experimentation with new ideas without interupting the entire framework. Many of the features are implemented as components allowing simple replacement as desired. State of the Code - We consider the code feature complete with some real-world user scenarios implemented. The framework has not been used in a production environment yet, but we will base all our future project on it and switch older projects to this framework as needed. z3c.form This is the main package implementing the framework. It is 100% tested in a multitude of text files; start by reading README.txt, which provides you with an overview and priorities the text files for you. Unit Tests: 478 Documentation: 193k in 24 text files Architecture Layout: form-graph.png, widget-graph.png z3c.formui ~~ This package contains some base templates for DIV- and TABLE-based form layouts. Both layout options are implemented in different layers, allowing you to chose either layout default by simply adding the layer to your skin. z3c.formdemo Here you will find some small demo sub-packages that demonstrate the framework as it is to be used: * Hello World Message A demo of adding, editing and displaying simple message objects. It demonstrates the simple usage of add, edit and display forms. It also adds another button to the edit form. * Widgets A simple form whose purpose is to demonstrate the completeness of the input widgets. All fields except Dict and Object have an input widget as demonstrated in the form. It also demonstrates how the content object retrieval can be customized in a form. * Calculator A simple calculator implemented as a form. The demo shows how to write different types of buttons, register handlers for those button types and hook in a custom action manager. * Wizard This simple, linear wizard demonstrates the sub-form capabilities of ``z3c.form``. Since these packages do not provide an object widget, this demostration also shows how this need can bebetter solved using sub-forms. * Table/Spreadsheet This little table allows you to add and edit a simple content component within a table. The table is rendered using the ```zc.table`` package demonstrating how the two packages can be used together. jquery.* The ``jquery`` namespace packages provide a first attempt to have AJAX-enabled forms. It is already possible to validate widget values and do some other form-unrelated UI goodies. The features within the ``jquery`` and form packages will soon be demonstrated in detail on the new www.zope.org website, which will also be available in code form as ``z3c.website``. So stay tuned! Installation All packages have been released in source and binary-egg format on PyPI and ``download.zope.org/distribution``. You can use setuptools to install them. Here is a list of all packages: * z3c.form * z3c.formui * z3c.formdemo * jquery.javascript * jquery.layer * jquery.widget Enjoy! Regards, Roger and Stephan ___ Zope3-users mailing list Zope3-users@zope.org
Re: [Zope3-Users] Does zope.app.file.Image works ?
Hey, On Sun, 2007-05-20 at 02:04 +0200, Christophe Combelles wrote: Hi, Is zope.app.file.Image functional ? I'm trying to use it, but uploading or reuploading an image doesn't do anything excepted sometimes when I'm lucky. Is it maintained and tested? (I'm on 3.3.1) Yep, z.a.file.image is functional. My guess from your implied statement that the problem is intermittent is that your browser may be loading a cached image. Shift-[click refresh] may help. Hope that does it. Regards, Darryl Christophe ___ 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] Does zope.app.file.Image works ?
Hey, On Sun, 2007-05-20 at 11:19 +0200, Christophe Combelles wrote: actually not. :( Pity, it seemed like such an easy answer. I've never struck the problem of only some files uploading. I have a small set of jpg images coming from different sources. Only two of them can be uploaded. The other ones don't upload at all, and validating the form just leads me again to the empty adding form. If I upload one that can be uploaded, no further modification can be done, and reuploading a different image does nothing, even if I shift-reload or use a different browser, or work on a new clean instance (without any added code) You might want to take a look at z3c.widget.image for an alternate widget. Regards, Darryl Christophe Darryl Cousins a écrit : Hey, On Sun, 2007-05-20 at 02:04 +0200, Christophe Combelles wrote: Hi, Is zope.app.file.Image functional ? I'm trying to use it, but uploading or reuploading an image doesn't do anything excepted sometimes when I'm lucky. Is it maintained and tested? (I'm on 3.3.1) Yep, z.a.file.image is functional. My guess from your implied statement that the problem is intermittent is that your browser may be loading a cached image. Shift-[click refresh] may help. Hope that does it. Regards, Darryl Christophe ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Arranging widgets in a form / Limit size of input fields
Hi, On Wed, 2007-05-02 at 15:07 +0200, Hermann Himmelbauer wrote: Hi, I'd like to know how to arrange (e.g. group) widgets in a form with formlib. One way would be to create a custom template file, where each widget is placed via HTML. However, this is quite some work. I've often done this and it doesn't seem like too much work. But I don't dispute your evaluation. Another way would be to place the fields via CSS. How do you deal with form layout? Moreover I wonder if it's possible to customize the attributes size and maxlength of HTML input fields via the zope schema. Schemas offer the attribute max_length, however this does not affect the rendered HTML - size seems to be always set to 20, maxlength is never set. My approach is different to Fred's because I rarely call setUpWidgets in my form code. I have a bunch of custom widgets in a known place and use custom_widget. Some widgets are for special fields or needs and some are as simple as this one. I reuse it very often.: class DescriptionWidget(TextAreaWidget): def __init__(self, context, request): super(TextAreaWidget, self).__init__(context, request) self.height = 3 self.width = 85 Best regards, Darryl Cousins Is there any solution to this? Best Regards, Hermann ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with @@absolute_url
Hi, On Mon, 2007-04-30 at 22:23 +0200, Maciej Wisniowski wrote: class StudentDetails: Helper to return a student photo. def getPhoto(self): student = self.context return StudentPhoto(student) In my page template, I can see that the IImage object is being created correctly.. div tal:define=photo view/getPhoto span tal:content=photo#/span /div gives me zope.app.file.image.Image object at 0xb75c6c6c. But to turn this object into a URL so that I can put it in an img tag is beyond me. When I try to do an @@absolute_url on the photo object I get the error saying there's not enough context. Am I going about this the wrong way? Is there some other thing I need to be doing in order for there to be enough context? Hm... not sure if it is good solution but it is just a quick though so possibly somebody may give you something better. Maybe there are ready solutions for this. In general if you want to return image then you have to return it's data to the browser (not Image object) and you also have to set proper headers like content-type and content-length. I don't remember exactly how it should go but you should find examples with google or see how z3c.image does this etc. This should be something like: class StudentDetails: Helper to return a student photo. def __call__(self): student = self.context self.request.setHeader('content-type', 'image/png') # determine and set content-length here return StudentPhoto(student).data # not sure if it was 'data' # check image.py If you declare this in zcml as: browser:view name='myphoto' class=StudentDetails' permission='zope.Public' for=. then you may use url just like: student_object/myphoto and this will execute __call__ method of the view class. Maciej's code should do it for you but will need to be a browser view: class StudentPhotoView(BrowserView): etc browser:view name='myphoto' class=StudentPhotoView' permission='zope.Public' for=IStudent / Also take a look at zope.app.file.browser.image.py for ImageData which takes the trouble to set the correct headers (which Maciej also implies). Hope this helps. Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Time for a Decimal field type in zope.schema?
Hi, No I don't know that it did. I wasn't at time a contributor to Zope. I am now however so I have no excuse. http://projects.treefernwebservices.co.nz/tfws.org.nz/file/trunk/src/tfws/field/README.txt Best regards, Darryl On Fri, 2007-04-27 at 20:37 +0800, Adam Summers wrote: Hi, Did the inclusion of Darryl's code ever get off the ground? I can't find a Decimal in zope.schema in Zope3.3.1 ... Regards, Adam Marius Gedminas wrote: On Thu, 31 Aug 2006 20:29:49 +0700 Darryl Cousins [EMAIL PROTECTED] wrote: On Thu, 2006-08-31 at 15:07 +0300, Marius Gedminas wrote: I am going to work on this today. For what it may be worth, a Decimal field: Code: http://projects.treefernwebservices.co.nz/tfws.org.nz/file/trunk/src/tfws/field/field.py Doctest: http://www.tfws.org.nz/tfws.field.README.html Looks nice. Would you consider contributing it for the inclusion into the Zope 3 core? (I see that it is already licenced under the ZPL, but I do not think I can just commit it into the Zope 3 repository under a different name.) I am attaching the diff showing my current working version, which mirrors the existing zope.schema.Float field more closely. As far as I can tell your field/widget is better. The only thing I do not see is a registration for a IDisplayWidget. Marius Gedminas ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Interfaces in Schemas
Hi, On Wed, 2007-04-18 at 09:21 -0700, Martin Aspeli wrote: Hermann Himmelbauer wrote: Hi, I wonder if it's possible to define attributes in a schema that reference other interfaces. For instance, I have a schema for a car and another one for a wheel and what I want to do is something like that: class IWheel(Interface): type = TextLine() class ICar(Interface): model = TextLine() wheel = ??? of type IWheel ??? wheel = schema.Object(schema=IWheel) or even better: wheel = List(min_length=4, max_length=4, value_type = ??? of type IWheel???) value_type=schema.Object(schema=IWheel) What would be really great now is if formlib could handle this and would automatically set up the needed widgets. Not sure what it does; I think you'd need to write some custom reference widget type thing; you can't fill in a wheel, really. :) Where would the Wheel objects come from? This tutorial will be enough to get you started with a custom widget for your List-Object field. http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent Best regards, Darryl Martin ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Formlib - handleSubmit, custom validator on action
Hi, On Thu, 2007-03-29 at 05:52 -0400, Fred Drake wrote: On 3/29/07, Darryl Cousins [EMAIL PROTECTED] wrote: but the line previous says data = {} So my validator always receives an empty dictionary to validate. The validator is responsible for populating `data` with the valid values. That's definitely covered in the docs somewhere. -Fred Cheers for the reply Fred. Indeed form.txt in formlib does say: If the validator is provided as a method name, the method will be called with the action and a dictionary in which to save data. Then the assumption is that the custom validator method will get the submitted values from the form object (also passed to the method along with the action and `empty` dictionary, though that isn't mentioned in form.txt). I'm thinking that the use-case for this functionality has been lost in development; historical flotsam. Who, after all, needs an empty dictionary passed to a method? And the method is expected to return quote form.txt a (usually empty) list of widget input errors. So what is the point of having an empty dict to populate? `data` itself is not returned, nor available outside the method, so your answer with the valid values makes little sense to me. But maybe I'm missing something? Sincere regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Formlib - handleSubmit, custom validator on action
Hi, On Thu, 2007-03-29 at 14:44 +0200, Philipp von Weitershausen wrote: Darryl Cousins wrote: On Thu, 2007-03-29 at 05:52 -0400, Fred Drake wrote: On 3/29/07, Darryl Cousins [EMAIL PROTECTED] wrote: but the line previous says data = {} So my validator always receives an empty dictionary to validate. The validator is responsible for populating `data` with the valid values. That's definitely covered in the docs somewhere. -Fred Cheers for the reply Fred. Indeed form.txt in formlib does say: If the validator is provided as a method name, the method will be called with the action and a dictionary in which to save data. Then the assumption is that the custom validator method will get the submitted values from the form object (also passed to the method along with the action and `empty` dictionary, though that isn't mentioned in form.txt). I'm thinking that the use-case for this functionality has been lost in development; historical flotsam. Who, after all, needs an empty dictionary passed to a method? And the method is expected to return quote form.txt a (usually empty) list of widget input errors. So what is the point of having an empty dict to populate? `data` itself is not returned, nor available outside the method, so your answer with the valid values makes little sense to me. But maybe I'm missing something? You are. The validator is not given just *any* empty dictionary, it is given the data dictionary that will later be passed to the action. OK. Then what I'm missing is how to assign a value to that variable `data` because in my code def my_validator(form, action, data): data = {'blah':'forgive me'} print data {'blah':'forgive me'} and a print statement in formlib/form.py directly after line 736: errors, action = handleSubmit(self.actions, data, self.validate) print data {} So I am always getting an empty dictionary back to my action method. Sorry for the noise. In the meantime I've just gone back to creating an interface with and @interface.invariant which is working for me. I was just keen to find out if validator could be used. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Cancelling AddForm
On Mon, 2007-03-12 at 16:18 +0100, Thierry Florac wrote: Hi, I have several formlib.form.AddForm subclasses in which I've created a custom Action via @action(...). My problem is that I'd like to be able to launch some of these actions (but not all of them, it's action specific) without executing automatic formlib controls (actually, for example, even a simple Cancel button which should just redirect the browser actually raises an exception when required fields are missing). Any help ? Thanks, Thierry Florac Hi Thierry, I implement cancel buttons for formlib like this (probably came from somewhere but I forget where):: def always_good(form, action, data): Helper for actions - will always validate - useful for cancel actions return [] class MyAddForm(form.AddForm): @form.action(_(Cancel), validator=always_good) def handle_cancel(self, action, data): self.request.response.redirect(self.nextURL()) Hope that helps, regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] correct display of Text field in a view
On Fri, 2007-03-09 at 10:06 +0100, Ivan Horvath wrote: - modify the description widget data with PlainTextToHTMLRenderer.render(), but then in the browser i can see only encoded chars instead of br Hi, As for Frank's suggestion try: p tal:content=structure view/description / when rendering the text2html content. That should allow the html tags through. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3.3.0 creating DTML page TypeError: readline() takes exactly 1 argument (2 given)
Hi David, There's probably more than one 'hello world' and certainly more than one way to do it. Here's one: http://www.treefernwebservices.co.nz/hello.html Get through this is worthwhile (its a big wiki): http://wiki.zope.org/zope3/ZopeGuideContents And hours to spend here: http://worldcookery.com/Appetizers Have fun. Darryl On Fri, 2007-03-09 at 18:06 -0800, David Christensen wrote: zope3-users: ... I guess the meta-question is: what's the best way to learn Zope?. STFW, I can't seem to find any Zope 3 tutorials, and the most recent online edition of The Zope Book seems to cover version 2.6. Should I attempt to read/follow that version of the book using Zope 3 and discover the differences, or would I be better off installing Zope 2.6? TIA, David ___ 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
[Zope3-Users] z3c.sampledata experts please
Hi, My initial start with z3c.sampledata was enthusiastic but now I don't know where to go. The simple scenario is to build sampledata with: A site A photo utility in etc A photo folder I register the utility:: adapter name=tfws.gallery.utility factory=.generator.testPhotoUtilityDataFactory for=z3c.sampledata.interfaces.ISampleDataPlugin provides=.generator.IPhotoUtilityDataSource / SampleManager name=Sample photo utility generator name=tfws.gallery.utility dataSource=tfws.gallery.utility contextFrom=z3c.sampledata.site / datasource name=tfws.gallery.utility adapterName=tfws.gallery.utility adapterInterface=.generator.IPhotoUtilityDataSource / /SampleManager This works just fine. I have a print statement in the utility generator:: print context.__name__ which prints the chosen name for the sample site. Now I try to add in the photofolder:: utility name=tfws.gallery.photofolder factory=.generator.SamplePhotoFolder provides=z3c.sampledata.interfaces.ISampleDataPlugin / adapter name=tfws.gallery.photofolder factory=.generator.testPhotoFolderDataFactory for=z3c.sampledata.interfaces.ISampleDataPlugin provides=.generator.IPhotoFolderDataSource / SampleManager name=Sample photofolder generator name=tfws.gallery.photofolder dependsOn=z3c.sampledata.site tfws.gallery.utility contextFrom=z3c.sampledata.site dataSource=tfws.gallery.photofolder / datasource name=tfws.gallery.photofolder adapterName=tfws.gallery.photofolder adapterInterface=.generator.IPhotoFolderDataSource / /SampleManager The dependsOn is maybe where I am going wrong though I have tried numerous approaches. What happens here is the generator form shows me the 3 samples I want to generate: site, utility and photofolder but on submit I get File /opt/zope/sandbox/lib/python/tfws/gallery/utility/generator.py, line 89, in generate sm.registerUtility(util, self.interface) ForbiddenAttribute: ('registerUtility', LocalSiteManager ++etc++site) The print statement that I mentioned above shows context.__name__ as None so the utility is not installing to the generated site as I expected. I verify this by trying to generate the utility without sample site - ie with context as the zope app root, and I get the same error. I need a bit of advice here, because I want to go forward and generate a large set of sampledata with a site, half a dozen local utilities and numerous content components. But as you see I can't get a single component in place with a dependency on a single utility. Some of my components depend on more than one utility. Help and advice is definitely required. Thanks, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.sampledata experts please
Hi, I've found something which may help someone help me. I have placed the following in z3c.sampledata.manager in the generate method: def generate(self, context=None, param={}, seed=None): plugins = self.orderedPlugins() for info in plugins: print info.name, info.name print info.contextFrom, info.contextFrom When I run the sample generator for the utility alone I get: info.name z3c.sampledata.site info.contextFrom None info.name tfws.gallery.utility info.contextFrom z3c.sampledata.site BUT when run with photofolder I get info.name z3c.sampledata.site info.contextFrom None info.name tfws.gallery.utility info.contextFrom None info.name tfws.gallery.photofolder info.contextFrom z3c.sampledata.site So I'm trying to discover why the contextFrom for the utility is lost. The most relevant configuration is below. SampleManager name=Sample photo utility generator name=tfws.gallery.utility dataSource=tfws.gallery.utility dependsOn=z3c.sampledata.site contextFrom=z3c.sampledata.site / datasource ... / /SampleManager SampleManager name=Sample photofolder generator name=tfws.gallery.photofolder dependsOn=z3c.sampledata.site tfws.gallery.utility contextFrom=z3c.sampledata.site dataSource=tfws.gallery.photofolder / datasource ... / /SampleManager ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Strange - You are not authorized
Hi Alek, On Mon, 2006-10-23 at 11:57 +0200, [EMAIL PROTECTED] wrote: Hello, I have a strange behavior of my content object. I have defined browser:editform for it and proper class directive (with zope.Public permissions) and I get only the following message in browser, even when logged in as Manager: Unauthorized - You are not authorized I don't have any error/exception on console. Mulitiple interfaces are probably not the source of the problem. I guess you are looking at the ZMI? You can click on 'errors' and 'configure' the utility to also record Unauthorized exceptions. This will give you a traceback to begin tracking your problem. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ForbiddenAttribute when adding to a folder
Hi Tim, On Sat, 2006-10-21 at 12:18 +0200, Tim Terlegård wrote: Is there a way to add content without having @@+ in the URL? For instance I'd like the url for adding events to be /addEvent. I get security problems when not having @@+ in the URL. I have this view: browser:page for=zope.app.container.interfaces.IWriteContainer name=addEvent class=.eventforms.EventAddForm permission=zope.ManageContent / When I hit the submit button in this add form I get an error: ForbiddenAttribute: ('add', zope.app.folder.folder.Folder object at 0xb6e65d2c) Forbidden here in the sense that Folder does not have an 'add' attribute. I realize IWriteContainer might not be the right interface, it doesn't have any add method. Should I have for=zope.app.container.interfaces.IAdding instead and somehow add an adapter from IFolder to IAdding or how would I do this? Tim As you point out formlib.BaseAddForm calls the add method of the context: _finished_add = False def add(self, object): ob = self.context.add(object) self._finished_add = True return ob I (also a novice) always use formlib for adding. But I use my own base adding sub-class of BaseAddForm which has this add method: def add(self, obj): try: ob = self.container.add(obj) except: self.container.__setitem__(obj.__name__, obj) ob = self.container[obj.__name__] self._finished_add = True return ob I almost always use a NameChooser to choose the name for the object. So I can trust using __name__ as the dict key. I use self.container here that usually resolves to self.context but on some occassions the context is not the container I want to be adding to. Hopes this helps. Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Missing the point
Hi Luiz, Too much coding without beer is no fun. Too much beer and coding gets messy. I've been guilty of both. :-) There is a recent thread that I think applies to your questions, one mail of which is: http://mail.zope.org/pipermail/zope3-users/2006-October/004664.html which includes a link to: http://blogs.lovelysystems.com/srichter/2006/09/20/the-skin-browser-and-lovely-systems-new-development-workflow/ Yes, Zope3 does require a lot of configuration/zcml work. But as an example I have recently been building a site where the work was in just building and configuring views (and a few adapters) on content objects that were already developed for another project. It has been fun - even without beer. Hope this helps. Darryl On Fri, 2006-10-13 at 22:06 -0300, Luiz Fernando Bernardes Ribeiro wrote: Hello all, I've been studying zope3 for some time and have been working with zope2 for some years but I still think I'm missing the point with the new patterns in Zope3. I would like to hear the opinion of some of you. I have developed a portal product with many content types to be used inside, each one has all the fields and logic needed to operate them - but no views (no html files). This is needed because many clients will use the same portal and content types, each one with its own templates. I feel it is too much to have to write classes, register every single image, javascript, css and fill the templates with tal:attributes to locate the resources, just to build the presentation layer for the products, all logic is already contained in them. I was thinking in something like zope2, just upload the html files, folders, images and so on... using webdav or FTP and access the methods and fields in the objects created in each client deployment. I know this model is possible in zope3 but considering the absence of any example using this pattern, I feel I may be going in the wrong direction. We are a web application shop in Brazil and we need to provide shared host and reusable components to many clients. All the examples found focused on one single application inside a zope3 server. Will I have to restart zope3 for every single update on the code? We need centralized code for content types (zope3 is great on this) but we need simple and independent interfaces (views) for each implementation. What is the best pattern for this? Sorry for being long... it is the effect of long time coding and no beer ;) Thanks in advance, -- Luiz Fernando B. Ribeiro ___ 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] virtual hosting
On Wed, 2006-10-11 at 04:57 -0500, Hector Miuler Malpica Gallegos wrote: Hello friends, as I can have virtual hosting of easy form? like in zope2 -- Hector Miuler Malpica Gallegos [EMAIL PROTECTED] Sure. VirtualHost * ServerName zope3.theshire RewriteRule ^(/?.*) http://localhost:8031/++vh++http:zope3.theshire:80/++$1 [P,L] /VirtualHost Hope that helps. Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Seeking a ZCML Example for a CSSViewlet
On Mon, 2006-10-09 at 18:50 +0200, Thierry Florac wrote: Maybe I'm wrong, but it seems that the weight parameter is not used by the default implementation of the CSS viewlet manager... Correct ? Thierry Florac Hi, Yes you are right. Sorry for throwing in the confusion. Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Seeking a ZCML Example for a CSSViewlet
On Fri, 2006-10-06 at 20:29 -0500, Jeff Rush wrote: I've got viewlets working fine (really cool too!) but I'm stumped on getting a CSSViewlet declared. Googling doesn't show anyone using CSSViewlets but hopefully someone who implemented it might clarify. Help please? -Jeff Hi Jeff, I do it like this (forgetting where the boilerplate came from - thanks to someone).: python code:: BRSPublicLayerLayoutCSSViewlet = zope.viewlet.viewlet.CSSViewlet('style/layout.css', 'all') configure zcml:: browser:viewlet name=layout.css for=* manager=barrysmithgallery.layer.public.ICSS permission=zope.Public class=..BRSPublicLayerLayoutCSSViewlet layer=barrysmithgallery.layer.public.IBRSPublicBrowserLayer weight=2 / And the manager: python code:: class ICSS(zope.viewlet.interfaces.IViewletManager): configure zcml:: browser:viewletManager name=barrysmithgallery.layer.public.ICSS provides=barrysmithgallery.layer.public.ICSS layer=barrysmithgallery.layer.public.IBRSPublicBrowserLayer permission=zope.Public / And it gets into main template:: tal:block replace=structure provider:barrysmithgallery.layer.public.ICSS / Hope this helps. Best regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Unicode and vocabularies
Hi, I'm having some trouble with unicode and vocabularies. I've a utility with a List field: class MyUtility(Interface): mylist = List(title=_(My List), value_type = TextLine(_(list item)), default = [], required = False) When the utility is created the list is populated from a unicode text file: datadir = os.path.join(os.path.dirname(__file__),'data') source_file = os.path.join(datadir, 'medium.dat') fp = codecs.open(source_file,r,'utf-8') options = [] for line in fp.readlines(): options.append(line.strip()) util.medium = options fp.close() The file contains é (e-acute). I came to the above routine to fix a 'Wrong Type' error for the list. Now when I come to create a vocabulary from the list: class MyVocabulary(object): def __call__(self, context): utility = zapi.getUtility(IMyUtility) items = [item for item in utility.medium] return SimpleVocabulary.fromValues(items) It raises error ... File /opt/zope/zope3/src/zope/schema/vocabulary.py, line 41, in __init__ self.token = str(token) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 13: ordinal not in range(128)with vocabulary code: I can't figure out how to get the correct unicode value into the utility list and yet still have str(u'é') work when vocabulary factory is called. Best regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Autocreated content objects
On Wed, 2006-09-27 at 11:13 +1000, John Maddison wrote: Ah, I think I may have misdescribed what I was trying to do - I'm not trying to replace the root object, I'm trying to automatically create some other objects to put inside it (without having to use the ZMI). Hi John, Maybe we are back at my answer? There is zc.buildout for full installation set up and z3c.configurator, neither of which I've gained experience with - yet. They are still a rung or two up my learning curve. (Mixing metaphors). For my simple attempts I use a straight forward python method:: class AddSampleGallery(BrowserView): Install script for a sample gallery def install(self): root = self.context root['myapp'] = MyApp() And slot it in a menu with zcml:: browser:page for=zope.app.folder.interfaces.IFolder name=addSampleGallery.html permission=zope.ManageSite class=.install.AddSampleGallery attribute=install / browser:menuItem menu=zmi_actions title=Add sample gallery for=zope.app.folder.interfaces.IFolder action=addSampleGallery.html permission=zope.ManageSite / The install method obviously does a lot more including sample content, principals etc. And then there is a subscriber to the application's IObjectAddedEvent which does set up only possible after the content is located. Regards, Darryl ___ 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] Autocreated content objects
Hi John, This may be what you are after: root['my-app'] = MyApp() Regards, Darryl On Mon, 2006-09-25 at 17:21 +1000, John Maddison wrote: Hi there, Is it possible/wise to auto-create content objects in the ZODB? Say I'm creating a blog application and have a container type(BlogContainer) and want an instance called blog in the root of the ZODB. Is it possible to programatically specify this, or is my only option to create it through the ZMI? I thought that perhaps an event was generated when the root object was created that I could hook into, but it seems not. Perhaps I'm looking at this the wrong way - would fixtures like this be better implemented as utilities with z3c.traverser redirecting to appropriate views? John ___ 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] zpt pages though ZMI
Hi, Your problem is in /home/hassan/HOMEPAGE2/modules/ISI/skin/template_tablelayout.pt and UnauthenticatedPrincipal does not have attribute 'title'. Check Boston skin template which first tests for authenticated user before calling request/principal/title. Regards, Darryl On Sun, 2006-09-24 at 19:43 +0900, Hassan Alirezaei wrote: Hello everyone, Does anyone know the easiest way to let people (principals of a site) develop their own pages with no knowledge about zop3 structure? AFAIK The users need to make their own pages with HTML (more generally ZPT) and upload them as a ZPT page. I dont want my whole website skin to disappear so I use the context/@@standard_macros/page for the zpt page. when I add it, the page renders fine for the Manager(ZCML) but not for other principals, apparently the title for each principal can not be traversed. this is my zpt page which I upload through the ZMI as Manager: html metal:use-macro=context/@@standard_macros/page /html and here is the error: --- File /usr/local/Zope-3.3.0c1/lib/python/zope/tales/tales.py, line 696, in evaluate return expression(self) - /home/hassan/HOMEPAGE2/modules/ISI/skin/template_tablelayout.pt - Line 59, Column 36 - Expression: PathExpr standard:u'request/principal/title' - Names: {'args': (), 'container': zope.app.folder.folder.Folder object at 0xb50880ac, 'context': zope.app.folder.folder.Folder object at 0xb50880ac, 'default': object object at 0xb7d44550, 'loop': {}, 'nothing': None, 'options': {}, 'repeat': {}, 'request': zope.publisher.browser.BrowserRequest instance URL=http://124.102.91.194:8080/ZPTPage, 'template': zope.app.zptpage.zptpage.ZPTPage object at 0xb50885ec, 'usage': zope.pagetemplate.pagetemplate.TemplateUsage object at 0xb503654c} File /usr/local/Zope-3.3.0c1/lib/python/zope/tales/expressions.py, line 217, in __call__ return self._eval(econtext) File /usr/local/Zope-3.3.0c1/lib/python/zope/tales/expressions.py, line 194, in _eval ob = self._subexprs[-1](econtext) File /usr/local/Zope-3.3.0c1/lib/python/zope/tales/expressions.py, line 124, in _eval ob = self._traverser(ob, element, econtext) File /usr/local/Zope-3.3.0c1/lib/python/zope/app/pagetemplate/engine.py, line 68, in __call__ request=request) File /usr/local/Zope-3.3.0c1/lib/python/zope/traversing/adapters.py, line 164, in traversePathElement return traversable.traverse(nm, further_path) - __traceback_info__: (zope.app.security.principalregistry.UnauthenticatedPrincipal object at 0xb7390b6c, 'title') File /usr/local/Zope-3.3.0c1/lib/python/zope/traversing/adapters.py, line 52, in traverse raise TraversalError(subject, name) - __traceback_info__: (zope.app.security.principalregistry.UnauthenticatedPrincipal object at 0xb7390b6c, 'title', []) TraversalError: (zope.app.security.principalregistry.UnauthenticatedPrincipal object at 0xb7390b6c, 'title') --- Not is this the expected behavior or am I doing something wrong??? thanks for any help. Hass ___ 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: Writing tests for views
On Sun, 2006-09-24 at 01:37 +0200, Philipp von Weitershausen wrote: George Lee wrote: I am trying to write a test for a view, and making sure that an object I've created is associated with the correct view. But either of these lines fails with a ComponentLookupError Couldn't find view: view = getView(self.event1, 'daterange_display', self.request) view = getViewProviding(self.event1, IDateRangeDisplay, self.request) Use getMultiAdapter. These things are deprecated. Which would look something like this: view = zapi.getMultiAdapter((self.event1, self.request), name=daterange_display) To register the view in python for a non-functional doctest something like this would work (maybe someone can correct me, because I've got IBrowserRequest twice in there but it does work): component.provideAdapter(YourViewClass, [IYourInterface, IBrowserRequest], \ ... IBrowserRequest, name='daterange_display') even though in a page template that I view through the web, context/@@daterange_display retrieves the correct view. What am I doing incorrectly? Well, is the test a functional test? Only functional tests have all the configuration loaded. Otherwise you'll have to register the view first before you can test its lookup. By the way, testing views is best done with zope.testbrowser these days. Yes. But all the same I do use a quick doctest to check that the view class behaves as expected before going on to testbrowser functional tests (which take longer to run). I save a bit of time then catching silly import and syntax errors and tuning the view class. Regards, Darryl Thanks -- I know I've asked a flood of questions today! Consider buying my book: http://worldcookery.com Also consider reading the docs that are there. Zope 3 has lots of docs (see http://localhost:8080/++apidoc++ after enabling devmode). There are also a couple of tutorials available at http://worldcookery.com/Appetizers. ___ 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: When I modify one class in my source code, I need always to restart zope server ?
I was just doing that. Done. Thanks to the Kerala connection. ;-) Regards, Darryl Why aren't these in a FAQ off the Zope3 page if they are common enough to respond like that? Please add this to FAQ :) Here is the link : http://kpug.zwiki.org/Zope3Faq Thanks, Baiju M ___ 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] Conflicting configuration actions for protectName __setitem__
Hi Rob, __setitem__ is likely also part of your IFosterRecord interface. class IFosterRecord(IContainer) #? and this is causing the conflict. Regards, Darryl On Tue, 2006-09-19 at 15:35 -0700, Rob Campbell wrote: I know I read about this error somewhere before, but I haven't been able to find anything through Google searches. I have a container that also has it's own attributes. I am calling zope.app.container.constraints.contains from IFosterRecord, is that what is causing the __setitem__ problem? Here is the traceback I have been getting: zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions For: ('protectName', class 'rats.foster.FosterRecord', '__setitem__') File /opt/zope/instance/lib/python/rats/configure.zcml, line 25.2-45.2 class class='.foster.FosterRecord' implements interface='zope.app.container.interfaces.IContainerNamesContainer' / require permission='zope.View' interface='zope.app.container.interfaces.IReadContainer' / require permission='zope.ManageContent' interface='zope.app.container.interfaces.IWriteContainer' / require permission='zope.View' interface='.interfaces.IFosterRecord' / require permission='zope.ManageContent' set_schema='.interfaces.IFosterRecord' / /class ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] zope.contentprovider and z3c.traverser
Hi, z3c.traverser and zope.contentprovider are helpful packages with good and clear doctests. It didn't much time to get up and running with them. However the packages do not include an example of how to configure my new useful code into my project. I got it figured (well, ... it works): http://kpug.zwiki.org/Zope3Faq#configuring-z3c-traverser-and-zope-contentprovider Sincerely thanks, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Registering adapter for ListSequence widget in tests
Ok. Thanks Tahara and Philipp. I am using component.provideAdapter. What I am having trouble with is registering ListSequenceWidget for use in a doctest. I believe the matching zcml from zope.form.browser configure is: view type=zope.publisher.interfaces.browser.IBrowserRequest for=zope.schema.interfaces.IList zope.schema.interfaces.IField provides=zope.app.form.interfaces.IInputWidget factory=.ListSequenceWidget permission=zope.Public / My own attempt to register the widget for a doctest is: zope.component.provideAdapter(ListSequenceWidget, \ ... [IList, IField, IBrowserRequest], \ ...IInputWidget) The error on running doctest is: ComponentLookupError: ((zope.schema._field.List object at 0xb704532c, zope.publisher.browser.TestRequest instance URL=http://127.0.0.1), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') The relavant part of the schema to be rendered is: addlanguage = List( title = _(Language), description = _(Add language to content), required = False, default = [], value_type = TextLine( title = _(Langauge))) Thanks, Darryl On Wed, 2006-09-06 at 09:41 +0200, Philipp von Weitershausen wrote: TAHARA Yusei wrote: At Wed, 06 Sep 2006 09:29:15 +0200, Philipp von Weitershausen wrote: TAHARA Yusei wrote: I think you should use zope.app.testing.ztapi.provideAdapter instead. No! ztapi.provideAdapter is discouraged. zope.component.provideAdapter is the recommended spelling. Oh, sorry. I did not know that... You couldn't have. It's not officially deprecated. It's just discouraged. ___ 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] Formlib examples
Cheers Stephan, I've made quite a bit of progress since my posting of almost a month ago with using formlib, espicially with more complex widgets. By keeping on reading the code and debugging I am getting (slowly) a grip on it. mpg.de has a good short tutorial that helped me with a sequence/object combo. Sincere regards, Darryl On Wed, 2006-09-06 at 06:23 -0400, Stephan Richter wrote: Unfortunately, there are less formlib code samples out there than it should be. I think the SchoolTool project has started using formlib, so you might find some samples there. Also, zope.webdev uses formlib. http://svn.zope.org/zope.webdev/ Unfortunately, this is all I have for you. I have plenty of customer code, but it would be too hard to extract for a response. Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Groups, Principals and Permissions
Hi Stephan, I forget already what I was doing wrong but after some digging in the code I must have found what I was missing. Thanks, Darryl On Wed, 2006-09-06 at 06:35 -0400, Stephan Richter wrote: So it 'appears' to me that the security looks up the groups differently? Or have I missed something? Your approach is all good. I cannot confirm having problems with groups and I am using them in a customer project. Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registering adapter for ListSequence widget in tests
Cheers Stephan, Yup. I added: provideAdapter(CollectionInputWidget,[ISequence, \ ...IBrowserRequest], \ ...IInputWidget) To the test and now more form can be rendered in the doctest. Many thanks, Darryl On Wed, 2006-09-06 at 06:58 -0400, Stephan Richter wrote: On Wednesday 06 September 2006 00:55, Darryl Cousins wrote: Following test setup formula in zope.app.form.browser I get this: provideAdapter(ListSequenceWidget,[IList,IField,IBrowserRequest], \ ...IInputWidget,) You need a second adapter adapting just IList to IInputWidget. Here is what the configuration of zope.app.form.browser does: view type=zope.publisher.interfaces.browser.IBrowserRequest for=zope.schema.interfaces.ISequence provides=zope.app.form.interfaces.IInputWidget factory=.CollectionInputWidget permission=zope.Public / Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: pau, testbrowser, HTTP Error 403: Forbidden
On Wed, 2006-09-06 at 06:45 -0400, Stephan Richter wrote: On Sunday 27 August 2006 08:14, Darryl Cousins wrote: Doesn't pass. I can't figure how to use the test to test for what I expect - which is of course an exception. Two choices that I commonly use for debugging: 1. print browser.contents; this will fail right away, but shows you the HTML that you can then anlyze and see what happened. Yup, excepting that here it just displays HTML of the unauthorised view. 2. Use browser.handleErrors = False and see what's coming through. This I found at the time and helped me out. Thanks, Darryl Regards, Stephan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Registering adapter for ListSequence widget in tests
Hi, I am having problems registering ListSequence widget, the following from my doctest: Although most widget adapters are registered in tfws.form.browser testing I had a lot of trouble with ListSequenceWidget - here I keep trying until I get it. This is the error raised when running the test:: ComponentLookupError: ((zope.schema._field.List object at 0xb704532c, zope.publisher.browser.TestRequest instance URL=http://127.0.0.1), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') If I can't get the widget registered for the test then I shall just have to give up on the test. All this is to try to register an adpater to IInputWidget for the schema:: addlanguage = List( title = _(Language), description = _(Add language to content), required = False, default = [], value_type = TextLine( title = _(Langauge))) It **does** work in the browser. Imports:: from zope.component import provideAdapter from zope.app.form.browser import ListSequenceWidget from zope.schema.interfaces import IList, IField from zope.app.form.interfaces import IInputWidget from zope.publisher.interfaces.browser import IBrowserRequest The zcml configure for same looks like this in zope.app.form.browser.configure:: view type=zope.publisher.interfaces.browser.IBrowserRequest for=zope.schema.interfaces.IList zope.schema.interfaces.IField provides=zope.app.form.interfaces.IInputWidget factory=.ListSequenceWidget permission=zope.Public / Following test setup formula in zope.app.form.browser I get this: provideAdapter(ListSequenceWidget,[IList,IField,IBrowserRequest], \ ...IInputWidget,) But no go. See error above. Best regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Time for a Decimal field type in zope.schema?
Hi Gary, Thanks for that. Yup, I'll follow up on your suggestion to become a contributor. May help overcome lack of confidence and hone my abilities. Coincidently I was working on Decimal and Currency today in building views for CurrencyUtility. Decimal field needed a display widget - UnicodeDisplayWidget didn't cut it because decimal.Decimal is security proxied in views. Code available at: svn://svn.treefernwebservices.co.nz/var/svn/tfws.org.nz/trunk/src/tfws In the meantime, copy paste it and say it's yours. ;-) Sincere regards, Darryl On Fri, 2006-09-01 at 09:40 -0400, Gary Poster wrote: Darryl, your decimal field changes would be welcome, as would a currency field. Unfortunately, having one person check in another's work in the Zope repository has legal complications, and in fact, in this transition period to the ZF, only ZC has the right to check in another's work. Generally, it is /much/ better for a contributor to check in his own work. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Time for a Decimal field type in zope.schema?
Hi, For what it may be worth, a Decimal field: Code: http://projects.treefernwebservices.co.nz/tfws.org.nz/file/trunk/src/tfws/field/field.py Doctest: http://www.tfws.org.nz/tfws.field.README.html And a currency type which uses it: Code: http://projects.treefernwebservices.co.nz/tfws.org.nz/file/trunk/src/tfws/currency/app.py Doctest: http://www.tfws.org.nz/tfws.currency.README.currency.html Courteous thanks to plonemall. Sincere regards, Darryl On Thu, 2006-08-31 at 15:07 +0300, Marius Gedminas wrote: On Fri, 7 Apr 2006 09:37:02 -0400 Gary Poster [EMAIL PROTECTED] wrote: On Apr 7, 2006, at 8:35 AM, Jeff Rush wrote: Perhaps this is an old topic, although I've done searches. I've seen the brief discussion about security proxies and the Decimal type on zope3-users, but (to zope3-dev) what about getting it added to the zope.schema as a first-class field type? So we can have auto-generated HTML forms and such? Has anyone already done this, in some Zope3 branch or private development? Not as far as I know. If not, is there any good reason it should not happen? Must Zope3 support Python versions prior to the introduction of the Decimal type? Not as far as I know. I'm willing to tackle it and make a submission, otherwise. +1 I am going to work on this today. Marius Gedminas ___ 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] Time for a Decimal field type in zope.schema?
Hi Marius, Cheers. I don't have checkin rights so I'll leave it to you (or another) if it considered is worthwhile. Sincere regards, Darryl. On Fri, 2006-09-01 at 00:21 +0300, Marius Gedminas wrote: I committed my version (somewhat changed from the diff I posted here) into Zope 3 trunk. Feel free to update zope.schema.Decimal with features from your widget that my version doesn't have (like normalization to a given number of decimal points). reinventing-the-bicycle-proudly Marius Gedminas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Time for a Decimal field type in zope.schema?
Hi, Yes, I am aware of the use of a comma as a decimal place indicator, but was unsure how to handle it. Thanks Philipp for the hint. Sincere regards, Darryl On Thu, 2006-08-31 at 19:03 +0200, Philipp von Weitershausen wrote: Just a note: The format should be localized. In some countries 0,01 is used. (yes, a comma). I think you're confusing format and precision. Format is a rendering issue that heavily depends on the request or other language-sensitive contexts. We have the zope.i18n.locales machinery for that. It already covers the comma-vs-point problem. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: pau, testbrowser, HTTP Error 403: Forbidden
Cheers Philip for the reply. Yup. The site I am testing is set up with an initialization handler on the site folder, with the pau, groups, principals and other bits. The principal is logged in with this pau in the site folder (I can verify this with a testbrowser call to the principal account view. The browser tests which result in the behaviour I described is designed to test the security arrangement (on groups, principals and objects). I.E. I log in the principal with (exerpt from doctest): First up we'll use Kevin who is a member of the Member group only. When opening account view we will be asked to login. browser = Browser() browser.open('http://localhost/tfws/account.html') browser.getControl(name='login').value = u'kevin.lopez' browser.getControl(name='password').value = u'secret' browser.getControl(name='SUBMIT').click() browser.url 'http://localhost/tfws/account.html' And so I am suprised that: print browser.open('http://localhost/tfws/categories/cotton/edit.html') 'Unauthorized' in browser.contents True ... instead results in: Exception raised ... HTTPError: HTTP Error 403: Forbidden But in a browser I am redirected to the unauthorised view as expected. Best regards, Darryl On Sun, 2006-08-27 at 11:46 +0200, Philipp von Weitershausen wrote: Darryl Cousins wrote: Hi all, In normal browser when logged in as a pau principal I am successfully redirected to the standard unauthorized view when accessing a view forbidden to the user. But accessing the same view in tests using testbrowser and loggd in as the same principal I get: Exception raised: ... HTTPError: HTTP Error 403: Forbidden Any thoughts please? The PAU is a local utility stored in your ZODB. Functional tests (e.g. testbrowser tests) are run with an in-memory ZODB instance that's thrown away after each test (sandbox). They don't see the PAU you have set up. If you want to test authentication via your PAU in a test, the test should first create and register a PAU, add the principal sources inside and then add the principals (if necessary). Alternatively, you can just the 'mgr:mgrpw' credentials for functional tests. Philipp ___ 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: pau, testbrowser, HTTP Error 403: Forbidden
Hi Philipp, My choice of words is poor. No, I am not redirected, the url remains the same as typed but I do get a view which displays text saying 'Unauthorised, you are not' etc from zope/app/exception/browser/unauthorized.pt but the testbrowser doesn't give me this view. This behaviour suprised me and I don't yet see how to use the test. print browser.open('http://localhost/tfws/categories/cotton/edit.html') 'Unauthorized' in browser.contents True Doesn't pass and print browser.open('http://localhost/tfws/categories/cotton/edit.html') Exception raised: ... HTTPError: HTTP Error 403: Forbidden Doesn't pass. I can't figure how to use the test to test for what I expect - which is of course an exception. Sorry for the bother. Regards, Darryl On Sun, 2006-08-27 at 14:00 +0200, Philipp von Weitershausen wrote: Darryl Cousins wrote: Hi Philipp, Yup. Sorry I was unclear, I mean that in a browser (ZMI) I am redirected to the view which displays Unauthorised, you are not authorised' or similar. I am suprised therefore that I don't get the same view with testbrowser. Again, you're *not* redirected. Try to provoke an Unauthorized exception in a browser and watch the URL. It doesnt' change. Exception views are always displayed in place of the view you're supposed to see. There's no redirect. Philipp ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] pau, testbrowser, HTTP Error 403: Forbidden
Hi all, In normal browser when logged in as a pau principal I am successfully redirected to the standard unauthorized view when accessing a view forbidden to the user. But accessing the same view in tests using testbrowser and loggd in as the same principal I get: Exception raised: ... HTTPError: HTTP Error 403: Forbidden Any thoughts please? Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Groups, Principals and Permissions
Hi, I must be misunderstanding something with zope.app.authentication and using the classes directly as contained in that package. I have a PluggableAuthentication utility, registered, with GroupFolder and PrincipalFolder authenticator plugins. I have GroupInformations for groups in the group folder and InternalPrincipals for principals in principal folder. I have added principals to groups. All good, everything looks ok. But the principals do not 'inherit' the permissions assigned to the group (using PrincipalPermissionManager) they have been added to. I can get the groups for the principal easy enough: context = principal pau = zapi.getUtility(IAuthentication) members = pau['members'] principalid = pau.prefix + members.prefix + context.login groups = groupfolder.getGroupsForPrincipal(principalid) So it 'appears' to me that the security looks up the groups differently? Or have I missed something? Best regards, confused (as often is the case). Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] testbrowser hangs
Hi All, Just updated today to zope3 svn revision the latest trunk and my browser tests are hanging. After hunting for a while within my own package (assuming my own fault) I finally came up with a test that fails using a clean zope3 install with none of my own configuration. It hangs on getControl (but not on every test). Seems that I can open browser instance and do a few things before it hangs. I can return self.mech_browser from getControl and I think it hangs on forms(). The hanging is determined btw, Ctrl-C isn't enough, it takes `kill -s 15 $PIDTEST`. I'm still not convinced that the problem doesn't lie with me and would like to know if I'm alone with it. For now I'll try an earlier revision (I was using rev 69228 prior to the update). Best regards, ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] testbrowser hangs
Cheers for the reply, I still think it might be me. I rolled back to the zope3 revision I had and it still hangs. Same with the 33 branch you suggested. This time I have attached the files that will cause the browser test to hang. I should just keep looking I guess. Regards, Darryl On Thu, 2006-08-17 at 11:57 +0530, Baiju M wrote: On 8/17/06, Darryl Cousins [EMAIL PROTECTED] wrote: Hi All, Just updated today to zope3 svn revision the latest trunk and my browser tests are hanging. After hunting for a while within my own package (assuming my own fault) I finally came up with a test that fails using a clean zope3 install with none of my own configuration. It hangs on getControl (but not on every test). Seems that I can open browser instance and do a few things before it hangs. I can return self.mech_browser from getControl and I think it hangs on forms(). The hanging is determined btw, Ctrl-C isn't enough, it takes `kill -s 15 $PIDTEST`. I'm still not convinced that the problem doesn't lie with me and would like to know if I'm alone with it. For now I'll try an earlier revision (I was using rev 69228 prior to the update). Today (Thursday, August 17 2006) is bugday to make 3.3 beta2, so please report this in collector. Also try 3.3 branch. svn co svn://svn.zope.org/repos/main/Zope3/branches/3.3 Zope33 Regards, Baiju M ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ## # # Copyright (c) 2005, 2006 Tree Fern Web Services Ltd # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ## tfws for Zope 3: Package tfws.address.browser $Id: ftests.py 281 2006-08-16 10:29:37Z darryl.cousins $ import unittest from zope.testing import doctest from zope.app.testing.functional import FunctionalDocFileSuite def test_suite(): return unittest.TestSuite(( FunctionalDocFileSuite( browser.txt, optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE), )) if __name__ == '__main__': unittest.main(defaultTest='test_suite') Get a browser started using the ftesting Manager from zope.testbrowser.testing import Browser browser = Browser() browser.addHeader('Authorization', 'Basic mgr:mgrpw') Add a folder browser.open('http://localhost/@@contents.html?type_name=BrowserAdd__zope.app.folder.folder.Folder') browser.getControl(name='new_value').value = u'test' browser.getControl('Apply').click() browser.open('http://localhost/test/EditMetaData.html') browser.getControl(name='dctitle').value = 'Test' browser.getControl(name='dcdescription').value = 'Test folder' browser.getControl(name='save').click() print browser.getControl(name='dctitle').value Test So far so good. Try another folder. browser.open('http://localhost/@@contents.html?type_name=BrowserAdd__zope.app.folder.folder.Folder') browser.getControl(name='new_value').value = u'test2' browser.getControl('Apply').click() browser.open('http://localhost/test/EditMetaData.html') browser.getControl(name='dctitle').value = 'Test 2' browser.getControl(name='dcdescription').value = 'Test folder' browser.getControl(name='save').click() print browser.getControl(name='dctitle').value Test 2 Try a test manager browser.open('http://localhost/test/addSiteManager.html') Try a utility browser.open('http://localhost/test/++etc++site/default/contents.html') browser.getLink('Unique Id Utility').click() browser.getControl('Apply').click() browser.getControl('Register this object').click() browser.getControl(name='field.actions.register').click() 'This object is registered' in browser.contents True Try anything browser.open('http://localhost/test/contents.html') browser.getLink('ZPT Page').click() browser.getControl(name='field.source').value = 'spanTest/span' browser.getControl(name='add_input_name').value = 'page' browser.getControl(name='UPDATE_SUBMIT').click() browser.getLink('page').click() And here the test hangs using 90+% of cpu. ctrl = browser.getControl(name='field.source') print ctrl #browser.getControl(name='form.source').value = 'spanMyTest/span' #browser.getControl(name='form.actions.apply').click() #'MyTest' in browser.contents
Re: [Zope3-Users] testbrowser hangs
Hi, Python version maybe? The timing is about right with a debian upgrade, I am now running Python 2.4.4c0. Guess I better figure out how to downgrade and see what happens then with the tests. Regards, Darryl On Thu, 2006-08-17 at 19:21 +1200, Darryl Cousins wrote: Cheers for the reply, I still think it might be me. I rolled back to the zope3 revision I had and it still hangs. Same with the 33 branch you suggested. This time I have attached the files that will cause the browser test to hang. I should just keep looking I guess. Regards, Darryl On Thu, 2006-08-17 at 11:57 +0530, Baiju M wrote: On 8/17/06, Darryl Cousins [EMAIL PROTECTED] wrote: Hi All, Just updated today to zope3 svn revision the latest trunk and my browser tests are hanging. After hunting for a while within my own package (assuming my own fault) I finally came up with a test that fails using a clean zope3 install with none of my own configuration. It hangs on getControl (but not on every test). Seems that I can open browser instance and do a few things before it hangs. I can return self.mech_browser from getControl and I think it hangs on forms(). The hanging is determined btw, Ctrl-C isn't enough, it takes `kill -s 15 $PIDTEST`. I'm still not convinced that the problem doesn't lie with me and would like to know if I'm alone with it. For now I'll try an earlier revision (I was using rev 69228 prior to the update). Today (Thursday, August 17 2006) is bugday to make 3.3 beta2, so please report this in collector. Also try 3.3 branch. svn co svn://svn.zope.org/repos/main/Zope3/branches/3.3 Zope33 Regards, Baiju M ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Formlib examples
Hi All, I am having an extraordinary amount of bother coming to grips with the formlib module. Could anyone offer up complex examples with multiple schemas and subforms; and as an extended topic, examples including custom fields and widgets. My own attempts to date have ended up unneccessarily complex and indeed I have found it necessary to fall back to templates and BrowserView, to my shame. Many thanks, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Total n00b to zope3 and apache.
Hi Steve, keep playing with the rewrite rule. Try without the zope part: RewriteRule ^(/?.*) http://localhost:8080/++vh++http:localhost:8000/++$1 [P,L] Then http://locahost:8000/ 'should' take you to the zope instance. I think that you would want to have the zope/ inside ^(/zope/?.*) On my setup (linux) I use several host names for my machine so I can have several instances running - apache on port 80. I find this more convenient than using the trailing 'zope/'. # first instance on 8031 NameVirtualHost * VirtualHost * ServerName zope3.theshire RewriteRule ^(/?.*) http://theshire:8031/++vh++http:zope3.theshire:80/++$1 [P,L] ... # second instance on 8032 VirtualHost * ServerName zope3test.theshire RewriteRule ^(/?.*) http://theshire:8032/++vh++http:zope3test.theshire:80/++$1 [P,L] ... # the first instance using boston skin VirtualHost * ServerName zope3boston.theshire RewriteRule ^(/?.*) http://theshire:8031/++skin++Boston/++vh++http:zope3boston.theshire:80/++$1 [P,L] ... # trac VirtualHost * ServerName trac.theshire ... I often find it useful to access the same instance with different server names so I can stay logged in as manager (http auth) on one and log in as different site users (cookie auth) to test security settings and only need one browser open. Hope that helps. Darryl NameVirtualHost localhost:8000 VirtualHost localhost:8000 Servername localhost ErrorLog var/apache2/log/zope.log CustomLog var/apache2/log/zope.log common RewriteEngine On RewriteLog var/apache2/log/rewrites.log RewriteLogLevel 0 RewriteRule ^/zope(/?.*) http://127.0.0.1:8080/++vh++\ http:%{SERVER_NAME}:8000/zope/++$1 [P,L] /VirtualHost ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Total n00b to zope3 and apache.
Hi, Your rewrite rule is incorrect. Here is something close to meeting your requirements. RewriteRule ^(/zope/?.*) http://localhost:8080/++vh++http:localhost:8000/zope/++$1 [P,L] The important bit is the ++vh++. You may want to start reading here: http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/VirtualHosting Hope that helps. Best regards, Darryl On Thu, 2006-07-27 at 12:46 -0700, Steve Juranich wrote: First off, let me say that I'm a total newbie to both Zope3 and Apache. So if this is an RTFM situation, please let me know and point me to the docs. But after two hours of googling and searching zope.org, all I can seem to find is stuff relevant to Zope2. I'm trying to do something (I thought was) really simple: get Apache (2.0.58) to serve as the front-end to a currently running ZServer process (with Zope 3.2.1). Judging from what I've found in my scrounging around the internet, I cooked up the following chunk of httpd.conf: NameVirtualHost localhost:8080 # The ZServer process's port VirtualHost localhost:8080 Servername localhost DocumentRoot /absolute/path/to/apache2/htdocs ErrorLog var/apache2/log/zope.log CustomLog var/apache2/log/zope.log common RewriteEngine On RewriteLog var/apache2/log/rewrites.log RewriteLogLevel 0 RewriteRule ^/zope(/?.*) http://localhost:8080/$1 [P,L] /VirtualHost So I start up the ZServer with zopectl... no problems. Then I fire up apache (listening on port 8000) with apachectl... no problems. So then I visit localhost:8000 and I get the apache test page. I visit localhost:8080 and I get the default Zope3 page. But when I try to visit localhost:8000/zope, I get a 404 error. zope.log is empty, rewrites.log is empty, and the apache error_log only has the client error requesting the non-existent resource. So I obviously don't know what I'm doing with this VirtualHost block. Could somebody please help me out? Thanks a bunch. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Adapters and getters and setters
Hi Phillip, Cool. Thanks very much for that! Best regards, Darryl On Tue, 2006-07-25 at 10:16 +0200, Philipp von Weitershausen wrote: # account for everything in the IBuddy interface for field in IBuddy: locals()[field] = property( lambda self: getattr(self.context, field), lambda self, value: setattr(self.context, field, value) ) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] adding indexes in a __init__ method
Hi Lorenzo, The key reference adapter can only get a key reference **after** the object is added to the database (because it uses _p_oid). The problem could be fixed with a subscriber to IObjectAddedEvent:: def FilterableContainerInitializationHandler(object, event): Initialize container after its ObjectAddedEvent. # I have checks here too (maybe unecessary) if not IObjectAddedEvent.providedBy(event): return if not IFilterableContainer.providedBy(object): return # whatever needs to be done # self._catalog ... This handler is configured:: !-- initialization handler -- subscriber for=.IFilterableContainer zope.app.container.interfaces.IObjectAddedEvent handler=.subscribers.FilterableContainerInitializationHandler / Hope that helps. Best regards, Darryl On Tue, 2006-07-25 at 11:26 +0200, Lorenzo Gil Sanchez wrote: Hi, I have a special Folder content. When an instance of this class is created I want to create a catalog and an index in its __init__ method. Something like: class FilterableContainer(BTreeContainer): implements(IFilterableContainer) def __init__(self): super(FilterableContainer, self).__init__() self._catalog = LocalCatalog() self._catalog['attr1'] = FieldIndex(field_name='attr1') where LocalCatalog is a subclass of Catalog that only indexes objects that belong to its parent. The problem arises when I add my FieldIndex to my internal catalog. Some events are triggered and at the end I got this exception: File /opt/Zope-3.2.1/lib/python/zope/app/keyreference/persistent.py, line 41, in __init__ raise zope.app.keyreference.interfaces.NotYet(object) NotYet: zope.app.catalog.field.FieldIndex object at 0x2aaab3609b90 It happens because the key reference adaptor to Persistent thinks my FieldIndex object is already stored in the database, which is not the case. Anybody knows how should I add an index to my catalog in the __init__ method? Thanks in advance Lorenzo ___ 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] adding indexes in a __init__ method
Hi again, I was a too hasty. Because it is the FieldIndex that is missing the _p_oid attribute, and the fix I offered is for the container. Sorry about that. I need more thinking. Regards, Darryl On Tue, 2006-07-25 at 22:10 +1200, Darryl Cousins wrote: Hi Lorenzo, The key reference adapter can only get a key reference **after** the object is added to the database (because it uses _p_oid). The problem could be fixed with a subscriber to IObjectAddedEvent:: def FilterableContainerInitializationHandler(object, event): Initialize container after its ObjectAddedEvent. # I have checks here too (maybe unecessary) if not IObjectAddedEvent.providedBy(event): return if not IFilterableContainer.providedBy(object): return # whatever needs to be done # self._catalog ... This handler is configured:: !-- initialization handler -- subscriber for=.IFilterableContainer zope.app.container.interfaces.IObjectAddedEvent handler=.subscribers.FilterableContainerInitializationHandler / Hope that helps. Best regards, Darryl On Tue, 2006-07-25 at 11:26 +0200, Lorenzo Gil Sanchez wrote: Hi, I have a special Folder content. When an instance of this class is created I want to create a catalog and an index in its __init__ method. Something like: class FilterableContainer(BTreeContainer): implements(IFilterableContainer) def __init__(self): super(FilterableContainer, self).__init__() self._catalog = LocalCatalog() self._catalog['attr1'] = FieldIndex(field_name='attr1') where LocalCatalog is a subclass of Catalog that only indexes objects that belong to its parent. The problem arises when I add my FieldIndex to my internal catalog. Some events are triggered and at the end I got this exception: File /opt/Zope-3.2.1/lib/python/zope/app/keyreference/persistent.py, line 41, in __init__ raise zope.app.keyreference.interfaces.NotYet(object) NotYet: zope.app.catalog.field.FieldIndex object at 0x2aaab3609b90 It happens because the key reference adaptor to Persistent thinks my FieldIndex object is already stored in the database, which is not the case. Anybody knows how should I add an index to my catalog in the __init__ method? Thanks in advance Lorenzo ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] adding indexes in a __init__ method
Hi All, I was thinking about that del(self.field) that I threw in. Wouldn't that remove the object too and therefore the key reference? Apparently not (in the test anyway):: class TestField(Persistent): ... id = u'' ... def __init__(self, id): ... self.id = id class TestCaseTwo(Persistent): ... def __init__(self): ... self.field = TestField(id=u'test case two') ... def initfield(self): ... self.fieldkey = KeyReferenceToPersistent(self.field) ... del(self.field) t = TestCaseTwo() tc = root['t'] = t transaction.commit() tc.initfield() print tc.field Traceback (most recent call last): ... AttributeError:... print tc.fieldkey().id test case two transaction.commit() print tc.fieldkey().id # I thought this would fail test case two Best regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] adding indexes in a __init__ method
Hi Lorenzo, Cool. Where is the `contained` imported from? There is some magic there because I couldn't get the test to work when creating the FieldIndex in your createIndexes method without it. Thanks, Darryl On Tue, 2006-07-25 at 13:55 +0200, Lorenzo Gil Sanchez wrote: Hi Darryl, this is how I ended implementing it: ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Adapters and getters and setters
Hi All, I only recently began using formlib and I have used a schema to describe the form, and provided an adapter to adapt the object to the schema. It seems that formlib uses the adapter to access and set attributes on the object. To allow it to do that I need to provide getters and setters for the adapter to access the attributes on the object itself: class MyAdapterForMyObject(object): ... implements(IMyAdapter) ... def __init__(self, context): ... self.context = context ... def title(): ... def fget(self): ... return self.context.title ... def fset(self, value): ... self.context.title = value ... return locals() ... title = property(**title()) Before using formlib I would usually have a getContext() method on the adapter to return the adapted object and manually get or set the attributes (in the update method for example). Doing the above means I don't need to. Am I going about this the right way? Best regards, Darryl Cousins ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] searching and relations
Gary Poster wrote: If the relationship is intrinsic to one object's data model but not to the other's, then it makes sense to have a Python pointer on the first object. Hi Gary, Am I right that 'a Python pointer on the first object' is defined by simply defining the schema field, eg:: mypointer = Object( title=Pointer to object, schema=IInterfaceOfTheTarget) Then everything else will fall into place. I could even use formlib to edit the object being pointed to from within a form editing the 'first object'. The second object would not even know it is pointed to. For it to know I would need to use a relationship as you go on to discuss. Have a correctly understood? Regards, Darryl ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Persistent subclasses in tests
Hi, I've have a problem with the following and I hope someone can shed some light for me, I can't figure out what I am missing:: from ZODB.tests.util import DB import transaction db = DB() conn = db.open() root = conn.root() from persistent import Persistent p = Persistent() root['p'] = p Thats fine, but:: class TestItem(Persistent): ... pass item = TestItem() root['item'] = item transaction.commit() Traceback (most recent call last): File /opt/zope/zope3/src/zope/testing/doctest.py, line 1361, in __run compileflags, 1) in test.globs File doctest README.txt[28], line 1, in ? transaction.commit() File /opt/zope/zope3/src/transaction/_manager.py, line 96, in commit return self.get().commit(sub, deprecation_wng=False) File /opt/zope/zope3/src/transaction/_transaction.py, line 395, in commit self._commitResources() File /opt/zope/zope3/src/transaction/_transaction.py, line 495, in _commitResources rm.commit(self) File /opt/zope/zope3/src/ZODB/Connection.py, line 484, in commit self._commit(transaction) File /opt/zope/zope3/src/ZODB/Connection.py, line 526, in _commit self._store_objects(ObjectWriter(obj), transaction) File /opt/zope/zope3/src/ZODB/Connection.py, line 553, in _store_objects p = writer.serialize(obj) # This calls __getstate__ of obj File /opt/zope/zope3/src/ZODB/serialize.py, line 407, in serialize return self._dump(meta, obj.__getstate__()) File /opt/zope/zope3/src/ZODB/serialize.py, line 416, in _dump self._p.dump(state) PicklingError: Can't pickle class 'TestItem': attribute lookup __builtin__.TestItem failed ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Persistent subclasses in tests
Hi Gary, Thanks for that. For those who follow tests.py:: import unittest from zope.testing import doctest from zope.testing import module name = 'tfws.cart.README' def setUp(test): module.setUp(test, name) def tearDown(test): module.tearDown(test, name) def test_suite(): return unittest.TestSuite(( doctest.DocFileSuite('README.txt', setUp=setUp, tearDown=tearDown, optionflags=doctest.ELLIPSIS ), )) if __name__ == '__main__': unittest.main(defaultTest='test_suite') On Sun, 2006-07-23 at 20:59 -0400, Gary Poster wrote: On Jul 23, 2006, at 6:59 PM, Darryl Cousins wrote: Hi, I've have a problem with the following and I hope someone can shed some light for me ... Yup, you need to handle a case like that specially. See zope.testing.module Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Getting SOFTWARE_HOME
Hi David, Just for the record (because I know what you are getting at) I found this in zope/i18n/locales/tests: import os import zope.i18n locale_data = os.os.path.join(os.path.dirname(zope.i18n.__file__), 'locales', 'data') which does the job. Best regards, Darryl On Sat, 2006-07-22 at 12:37 -0300, David Pratt wrote: Can someone advise how get a handle of SOFTWARE_HOME on a running zope3 instance. Many thanks. Regards, David ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Where unauthorized is raised?
Hi, An update on this. When I change the permission on IMemberEditForm to zope.Public or zope.View then the form is displayed. Which is why I want to find the permission checker. The principal can view other objects protected by tfws.view but not this one. If I can find where the permission is being checked then perhaps I will find out why my principal is not passing the security checker and how I can fix it. Sorry if I'm getting hysterical. Regards, Darryl On Fri, 2006-07-21 at 19:33 +1200, Darryl Cousins wrote: Hi All, I'm having a permissions problem with a formlib form and an adapter. I have put the following in zope/schema/_bootstrapfields.py class Field ... def get(self, object): try: getattr(object, self.__name__) except: import sys print sys.exc_type, sys.exc_value return getattr(object, self.__name__) the print I get is: zope.security.interfaces.Unauthorized (tfws.portal.member.adapters.MemberEditFormForMember object at 0xb5b5bc8c, 'clear_photo', 'tfws.view') What I need to know is where is this Unauthorized being raised to debug further (as my principal indeed has the permission tfws.view). I need to pinpoint why. the only raise I can find that matches is in zope/security/checker but 'print's that I have added there give me nothing. Thanks, Darryl ___ 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] Where unauthorized is raised?
Hi, def __init__ ... self.context = self.__parent__ = context That's what I was missing in the adapter. Can I clarify this? The adapter is adapting an object (`self.context=context` in `__init__`). The field is getting an attribute from the security-proxied adapter. The permission is found on the adapter ('tfws.view') and the principal has this permission in the context, **but**; not on the adapter because the adapter has no 'location'. Only when I gave it a location with `self.__parent__` was the principal's possesion of the permission recognised as applying also to the adapter. Baiju: Probably one for your faq? Pester me. Likely be it, that somewhere is text that would have informed me. Damned if I could find it though. Excuse the noise. Cheers. Darryl PS: Where is that Unauthorized raised? # grep -R Unauthorized /usr/lib/python2.4/site-packages/zope/ | grep raise | uniq ... /usr/lib/python2.4/site-packages/zope/security/checker.py: raise Unauthorized(object, name, permission) ... That's the only one that matches, but I don't believe that is it. Maybe then in a .so? Curious. Darryl. On Fri, 2006-07-21 at 20:26 +1200, Darryl Cousins wrote: Hi, An update on this. When I change the permission on IMemberEditForm to zope.Public or zope.View then the form is displayed. Which is why I want to find the permission checker. The principal can view other objects protected by tfws.view but not this one. If I can find where the permission is being checked then perhaps I will find out why my principal is not passing the security checker and how I can fix it. Sorry if I'm getting hysterical. Regards, Darryl On Fri, 2006-07-21 at 19:33 +1200, Darryl Cousins wrote: Hi All, I'm having a permissions problem with a formlib form and an adapter. I have put the following in zope/schema/_bootstrapfields.py class Field ... def get(self, object): try: getattr(object, self.__name__) except: import sys print sys.exc_type, sys.exc_value return getattr(object, self.__name__) the print I get is: zope.security.interfaces.Unauthorized (tfws.portal.member.adapters.MemberEditFormForMember object at 0xb5b5bc8c, 'clear_photo', 'tfws.view') What I need to know is where is this Unauthorized being raised to debug further (as my principal indeed has the permission tfws.view). I need to pinpoint why. the only raise I can find that matches is in zope/security/checker but 'print's that I have added there give me nothing. Thanks, Darryl ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Newbie help with installing on Windows Server 2003
Hi Siddharth, What is the python version on your os? I googled 'strop functions are obsolete' and it seems to relate to older python versions. Hope this helps. Regards, Darryl Siddharth Sethi wrote: Hi, I am just starting out on Zope and have played around with the features somewhat on my windows xp system. The problem that i am having is that when i try to install zope 3.2.0 on my windows server 2003 system it gives me an error in command prompt -- warning: strop functions are obsolete; use string methods warning: strop functions are obsolete; use string methods warning: strop functions are obsolete; use string methods warning: strop functions are obsolete; use string methods ... and so on... Does anyone know a fix for this or if i am doing something wrong. I used the windows installer for this and it worked fine for me when i did on my winxp system but i don't know whats happening here. Siddharth Sethi ___ 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] Where unauthorized is raised?
Hi Takayuki, Thanks for that. I hadn't used PostmortemDebuggingHTTP before today. Regards, Darryl Takayuki Shimizukawa wrote: Hi Darryl. 2006/7/21, Darryl Cousins [EMAIL PROTECTED]: What I need to know is where is this Unauthorized being raised to debug further (as my principal indeed has the permission tfws.view). I need to pinpoint why. PostmortemDebuggingHTTP might teach the exception point. Please make PostmortemDebuggingHTTP effective with zope.conf, and use the port specified for URL. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
RE: [Zope3-Users] Where unauthorized is raised?
Cheers, Thanks for the reply. And I shall remember (he hopes). Regards, Darryl Roger Ineichen wrote: Yes, I use most the time locate=True. But right, set the parent explicit is also Ok. I don't thnk there is a preferred way. just remember, the missing location on a adapters is most the time responsible for permission lookup problems. Regards Roger Ineichen ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Formlib and invariants
Hi Florian, Yup. Thanks for that, much more elegant and passing in an error string displays nicely with error_views. Cheers, Darryl On Wed, 2006-07-19 at 22:18 +0200, Florian Lindner wrote: Am Mittwoch, 19. Juli 2006 03:25 schrieb Darryl Cousins: Hi All, I've had a bit of a struggle getting formlib error views to play nicely with invariants. That is the problem I have found to trouble me is in the zope.formlib.form.FormBase method error_views. When I use the schema: class IMemberRegisterForm(IMemberData, IMemberDetails): Schema for a member register form. new_password = Password( title=_(Choose a Password), required=True) verify_password = Password( title=_(Verify Password), required=True) @invariant def passwordsMatch(register): if register.new_password != register.verify_password: msg = _(Entered passwords do not match) error = ('verify_password', _(Passwords), msg) raise Invalid(error) [...] I am not sure if I've understood you correctly, but I've solved the same problem (raise error if passwords are not equal) this way: class PasswordsAreNotEqual(ValidationError): The passwords are not equal. interface.implements(IWidgetInputError) class IRegistrationForm(interface.Interface): For entering the data for registration. password = Password(title=uPassword, description=uYour password., required=True) password2 = Password(title=uVerify Password, required=True) @interface.invariant def arePasswordsEqual(obj): if obj.password != obj.password2: raise PasswordsAreNotEqual Hope this helps, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] A gentle push in the right direction needed
Hi Tim, My solution was to use an address container to act as the 'addressbook'. An adapter is used to attach (using annotations) the addressbook to any object which implements IHaveAddressInfo. Doctest: http://www.tfws.org.nz/tfws.portal.address.README.html Code: http://projects.treefernwebservices.co.nz/tfws.org.nz/browser/trunk/src/tfws/portal/address/ On Wed, 2006-07-19 at 21:22 +0100, Tim Penhey wrote: ... Now it is with the postal_address I hit my first snag. I really want to say that it is an IAddress. Am I using InterfaceField correctly here? Is there an option to specify the type of the interface? Also how do I specify a list of addresses? Thanks. Tim ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: testing setup
Hi Luis, You need to run functional tests using the zope testing environment which is set up for you when the tests are run with $instance/bin/test Functional tests are defined in python file ftests.py or package ftests/ which you will create in your package. For example: ftests.py:: import unittest from zope.testing import doctest from zope.app.testing.functional import FunctionalDocFileSuite def test_suite(): return unittest.TestSuite(( FunctionalDocFileSuite( README.txt, optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE), )) if __name__ == '__main__': unittest.main(defaultTest='test_suite') And then README.txt:: from zope.testbrowser.testing import Browser browser = Browser(’http://localhost’) browser.url ’http://localhost’ browser.contents ’...titleZ3: /title...’ Have a look at: http://zope-cookbook.org/cookbook/recipe07#x1-6000 And http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/ftests.html#x1-800043.3 And have a read of zope/testbrowser/README.txt There are other examples of tests in the source. Good luck. Regards, Darryl luis wrote: ... ### from zope.testbrowser.testing import Browser browser = Browser('http://localhost') ### just to see if I can open a connection to the test server... but if I try to run that code, I get this error message: ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] testing setup
On Wed, 2006-07-19 at 00:21 +0200, luis wrote: ... the problem is that now I'd like to create some functional tests like creating an object with my AddForm... I know there is a testbrowser, and I think I've read of another possibility to somehow record a human interaction once, and then reply it in the test, and somewhere I've seen a TestRequest as well...so what is the right way to do this through-the-web tests? I prefer to use testbrowser:: from zope.testbrowser import Browser browser = Browser() browser.open('http://localhost/contents.html') You'll probably need a manager to do anything at all:: from zope.testbrowser import Browser browser = Browser() browser.addHeader('Authorization', 'Basic mgr:mgrpw') browser.open('http://localhost/contents.html') See zope.testbrowser.README.txt. Yes, testbrowser creates a clean database and cleans up after itself (to the best of my knowledge). Regards, Darryl right now I'm trying to get the testbrowser to work, but all tests fail because the server is not running, so how do I tell the testing framework to start the zope server so that the testbrowser can connect to it? would the testing framework create a new instance with a clean database and remove it after the tests (or use a memory database), or just use the normal Data.fs ? thanks a lot for any help you can give me, luis ___ 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