[Zope3-Users] z3c.form - how to set single default values from another object?
Hi, Hi, I have here an add form which is based on an interface like this: class IMyObj(Interface): value1 = TextLine() value2 = TextLine() In my add form, I need to display a default value for value2. This default value is stored in another object, however, no default value should be given for value1. I'm desperatingly trying to implement this via z3c.form through various ways, but none seems to work. I had a look at widget.py, line 73 (the update method where the value is retrieved) and found the following: 1.1) From Request: I could solve my problem like the following in my update() method: self.request.form['form.widgets.value2'] = 'mydefault' However, I don't think it's a nice solution to modify the request for a default value. 1.2.1) Via a datamanger: Seems to be not possible as I can't explicitly set ignoreContext = False for a single widget. Therefore this fails as I don't have a datamanager for value1. Moreover it seems the datamanger is not a named adapter: value = zope.component.getMultiAdapter( (self.context, self.field), interfaces.IDataManager).get() Therefore in my case, where value1/value2 are both TextLines and have the same widget, it's not possible to register the datamanager for value2 only. 1.2.2) Via the field default value: Maybe possible by cloning the field in the update() method of my form and setting a default value there, however, this looks lie a _very_ bad style to me. 1.3) From an object attribute (don't really understand what this Step is for): Seems also not possible as there's once again no way to register a named adapter here and therefore the absence of value1 as object attribute will lead to an error: adapter = zope.component.queryMultiAdapter( (self.context, self.request, self.form, self.field, self), interfaces.IValue, name='default') So, either I missed somehow a good solution, or my pattern is not addressed in z3c.form. In this case, I'd suggest to handle this case in two ways: 1) Add e.g. Step 1.2.3, which queries after a named adapter where the name is the field name. This way, I'd be able to register an adapter that retrieves the default value from somewhere else. 2) Provide a way to tell single widgets (and not only the widget manager) to ignore/not ignore the context. This way, I could simply use the getContent() method in my view, although there's once again the same problem if the default values don't come from a single object (as my getContent routine cannot decide which object to return). I don't know if these two solutions would conflict with other parts of the framework, maybe there's an even better solution? Best Regards, Hermann -- [EMAIL PROTECTED] GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: How do you develop in zope 3?
[EMAIL PROTECTED] wrote: Hello, * How do you develop in zope 3? First a few words: After trying from time to time Zope 3 (X3, 3.0...) finally a month ago I jumped in full time. Thanks to Philipp von Weitershausen's book, my previous problems were solved. So I downloaded the zope 3 tar.gz and started to practice... only to discover eggs, buildouts, paster and friends (yes, pretty much I've been living under a programmer's rock). Well, no problem. After reading http://pypi.python.org/pypi/zopeproject/ and http://pypi.python.org/pypi/zc.buildout I was on track again. So basically, what I do is: # Create a virtual environment $ python2.4 bin/virtual-python.py --prefix=~/zope3/ # install easy_setup $ ~/zope3/bin/python bin/ez_setup.py # Install zopeproject (of course, all these steps are made just once) $ ~/zope/bin/easy_install zopeproject # make the projects $ ~/zope/bin/zopeproject webdev and then edit setup.py, buildout.cfg. and work in src/webdev. So long, so fine. But here come my doubts: *) Is it the way the experienced zope developers work? How do you set the environment for a site or a package development? Except for the zopeproject thing it is the way we work, edit the buildout.cfg and setup.py for the project needs. We also have a versions.cfg and nail all versions to the known working versions. Only update versions if really needed. *) I'm working in more than a package. I'm developing a blog, a user manager, etc. Should I create a new project for each package? How do I include in my site (under development) my packages (under development)? First of all each package should have it's full test environment to be able to developt the package independent of an application. If you want to use the current develop version in you application just set the develop path to your local working copy of the package. *) What recipe do you use to fetch a package via svn? We have no need to fetch packages using svn, we only use eggs. As stated above if you need to use a local develop version of a package we temporarily add a develop path for that package. Jürgen ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] if make check(test) failure, should I make install?
On Wed, Feb 20, 2008 at 09:22:06AM +0800, Fet Biz wrote: What to do next? If the make test results: -- Ran 9471 tests with 4 failures and 9 errors in 12 minutes 31.391 seconds. Tell us what version of Zope you were testing. Tests with errors: testInheritanceAcrossModules (zodbcode.tests.test_class.TestClass) testPersistentSubclass (zodbcode.tests.test_class.TestClass) testSavePersistentSubclass (zodbcode.tests.test_class.TestClass) testClass (zodbcode.tests.test_module.TestModule) testUpdateClass (zodbcode.tests.test_module.TestModule) testClassReload (zodbcode.tests.test_module.TestModuleReload) zodbcode is old, unmaintained and broken. This is not surprising. testAPPE (zope.server.ftp.tests.test_ftpserver.Tests) testSTOR (zope.server.ftp.tests.test_ftpserver.Tests) testSTOR_over (zope.server.ftp.tests.test_ftpserver.Tests) If you don't plan to use Zope's FTP server, ignore these. Tests with failures: checkOldStyleRoot (ZODB.tests.testPersistentMapping.PMTests) This one I'd be worried about. Can you post the full traceback? testPatch (zodbcode.tests.test_patch.TestPatch) testPASS (zope.server.ftp.tests.test_ftpserver.Tests) zodbcode and FTP again. /root/zope3/Zope-3.4.0c1/build/lib.linux-i686-2.4/zope/testing/testrunner-layers-ntd.txt I would like to see this traceback and then fix it. I've sort of volunteered to maintain zope.testing Judging from the pathname, you were testing Zope 3.4.0c1. Let me try it... Marius Gedminas -- Apologies for taking up the bandwidth with the apology. Anything else I can apologise for .. er no can't think of anything, sorry about that. Andy Hunt (Member of British Olympic Apology Squad) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How do you develop in zope 3?
On Tue, Feb 19, 2008 at 11:22:12AM -0400, [EMAIL PROTECTED] wrote: How do you develop in zope 3? The old-fashioned way, still. I haven't made the jump to eggs yet. So basically, what I do is: # Create a virtual environment $ python2.4 bin/virtual-python.py --prefix=~/zope3/ # install easy_setup $ ~/zope3/bin/python bin/ez_setup.py Check out virtualenv. It's a better virtual-python that automatically installs easy_install for you. # Install zopeproject (of course, all these steps are made just once) $ ~/zope/bin/easy_install zopeproject # make the projects $ ~/zope/bin/zopeproject webdev Marius Gedminas -- Every nonempty totally-disconnected perfect compact metric space is homeomorphic to the Cantor set. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form - how to set single default values from another object?
On Wed, Feb 20, 2008 at 01:10:57PM +0100, Hermann Himmelbauer wrote: Hi, I have here an add form which is based on an interface like this: class IMyObj(Interface): value1 = TextLine() value2 = TextLine() In my add form, I need to display a default value for value2. This default value is stored in another object, however, no default value should be given for value1. I'm desperatingly trying to implement this via z3c.form through various ways, but none seems to work. I am not familiar with z3c.form (being stuck with maintaining a project based on Zope 3.2 means you don't get to play with new toys). With zope.formlib you could solve this by passing an initial data dict to the setUpWidgets call. Doesn't z3c.form have something like that? You mentioned that you looked at the source where the widgets were updated. I suggest you look at the place where the widgets are created initialized. Marius Gedminas -- Nothing ever goes missing that they don't look at me, ever since that time I lost my horse. As if that could be helped. He was white and it was snowing, what did they expect? -- Dolorous Edd in A Storm of Swords by George R. R. Martin signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form - how to set single default values from another object?
On Wednesday 20 February 2008, Hermann Himmelbauer wrote: 1.3) From an object attribute (don't really understand what this Step is for): Seems also not possible as there's once again no way to register a named adapter here and therefore the absence of value1 as object attribute will lead to an error: adapter = zope.component.queryMultiAdapter( (self.context, self.request, self.form, self.field, self), interfaces.IValue, name='default') You almost got it. This is the approach that I envisioned. You basically have to provide this adapter to provide a default value. From z3c.formdemo.message.browser, line 27: DefaultDate = widget.ComputedWidgetAttribute( lambda adapter: datetime.date.today(), field=interfaces.IHelloWorld['when'], view=IAddForm) Then register the adapter as follows: adapter factory=.browser.DefaultDate name=default / You can create any function you like to compute the dynamic default value. The `adapter` argument has access to the context, request, form, etc. Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. Zope Stephan Richter ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: AW: AW: [Zope3-Users] z3c.form - howto ignore the context for singlewidgets in an Edit form?
On Monday 18 February 2008, Hermann Himmelbauer wrote: - Only widgets? - Combinations of schemas and widgets? - Also schemas without widgets (like an Email schema that inherits from a TextLine and thus uses a TextWidget)? These are good questions. We started already collecting the schema fields in z3c.schema. So I think z3c.formwidget should only contain the widgets and converters. Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. Zope Stephan Richter ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: AW: AW: [Zope3-Users] z3c.form - howto ignore the context for singlewidgets in an Edit form?
Am Donnerstag, 21. Februar 2008 04:41 schrieb Stephan Richter: On Monday 18 February 2008, Hermann Himmelbauer wrote: - Only widgets? - Combinations of schemas and widgets? - Also schemas without widgets (like an Email schema that inherits from a TextLine and thus uses a TextWidget)? These are good questions. We started already collecting the schema fields in z3c.schema. So I think z3c.formwidget should only contain the widgets and converters. Ah, ok, I was not aware of the z3c.schema package. Anyway, Roger suggested to solve this in another style by creating an egg for each schema and widget, e.g. z3c.schema.email, z3c.formwidget.email, z3c.schema.telephone, z3c.formwidget.telephone etc. He made some good points there, so I'm unsure which way to go? I think this leads to an eggsplosion, but Roger stated that this is exactly what the concept of eggs is all about. However, I'm still unsure that handling hundreds of eggs is really a viable way. For instance, I use z3c.form from the SVN repository, this way I always have the newest release via a simple checkout. However, it was quite some work to checkout/configure all other packages z3c.form needs, such as z3c.pagelet, z3c.formui etc. etc. So, in case of an eggsplosion, where a package has e.g. 50 dependencies, using an SVN version is a mess, especially when a SVN version depends on code available only in the SVN and not as Egg. Are such cases all really thought out? Best Regards, Hermann -- [EMAIL PROTECTED] GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users