Re: [Zope3-Users] z3c.form, german umlauts on buttons - small patch, please review
This small patch fixes the problem for me, please review: [EMAIL PROTECTED](~/tmp/z3c.form/src/z3c/form)$ svn diff Index: util.py === --- util.py (Revision 79574) +++ util.py (Arbeitskopie) @@ -30,7 +30,7 @@ def createId(name): if _identifier.match(name): return str(name).lower() -return name.encode('hex') +return name.encode('utf8').encode('hex') classTypes = type, types.ClassType [EMAIL PROTECTED](~/tmp/z3c.form/src/z3c/form)$ -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form, german umlauts on buttons
On Sun, Sep 09, 2007 at 11:20:34PM +0200, Roger Ineichen wrote: Hi Andreas Betreff: [Zope3-Users] z3c.form, german umlauts on buttons [...] My app is german only and if I was to introduce i18n I would still make german the primary language and English the second, i. e. I would still want @button.buttonAndHandler(_(u'Ändern')) I never did use German in the code and can't say that this should work. But why do you use german as the default language? I recommend to use english in the code and use german as a translated language. I'm not really sure if we should support german Umlauts at the python leven and take care for encoding. I guess this is what translation should be used for. Or not? Hi Roger, OK, let me put it this way: If I really have to use i18n for those umlauts on buttons (and that's what I might have to do if nothing changes) then you might be right in that it may be better to use English as the default language and German as one of the languages looked up by i18n, i. e. to use: @button.buttonAndHandler(_(u'Change')) and have i18n find Ändern as the German translation for Change. At least I guess this is what gettext docs would suggest. The other way around might not even be possible due to some gettext restriction - not sure about that. However, this particular app of mine will never be an international app, it will always be German only. It is just a simple app for a customer of mine here in Berlin, that's it, I just don't plan to make it a sophisticated multilanguage app. No need to negoatiate the languages accepted by the browser etc. - And till now, as long as I was using formlib, it was a simple app: as I pointed out, I could use something like this in formlib: actions[u'actions.aendern'].label=u'Ändern' It just feels awkward to make it more complex then was neccessary in the past. Besides, I can use umlauts in page templates without i18n - as utf-8 is the default there, just not on the buttons, this seems an assymetry to me. Also I specified the coding of my python file # -*- coding: utf-8 -*- which in py3k will be the default anyway, and buttonAndHandler() in z3c.form expects an unicode param, i. e. u'...', not just a plain string '...', doesn't it make sense to allow umlauts here - if ascii only is accepted then a plain string would have done it just as well. -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.form, german umlauts on buttons
It appears to me that I can't have german umlauts (or any other non-ascii chars for that matter) on buttons, for example (Ändern - with A umlaut - ist german for Change): # -*- coding: utf-8 -*- ... class MyDisplayForm(form.Form): ... @button.buttonAndHandler(u'Ändern') def change(self, action): self.request.response.redirect('edit') tons of error msgs: ... File /home/reuleaux/work/adrn/src/adrn/browser/views.py, line 489, in ? class MyDisplayForm(form.Form): File /home/reuleaux/work/adrn/src/adrn/browser/views.py, line 491, in MyDisplayForm @button.buttonAndHandler(u'Ändern') File /home/reuleaux/tmp/z3c.form/src/z3c/form/button.py, line 181, in buttonAndHandler f_locals['buttons'] += Buttons(button) File /home/reuleaux/tmp/z3c.form/src/z3c/form/button.py, line 83, in __init__ arg.__name__ = util.createId(arg.title) File /home/reuleaux/tmp/z3c.form/src/z3c/form/util.py, line 33, in createId return name.encode('hex') File encodings/hex_codec.py, line 24, in hex_encode zope.configuration.xmlconfig.ZopeXMLConfigurationError: File /home/reuleaux/work/adrn/parts/adrbuch/site.zcml, line 4.0-4.42 ZopeXMLConfigurationError: File /home/reuleaux/work/adrn/src/adrn/app.zcml, line 86.2-86.28 ZopeXMLConfigurationError: File /home/reuleaux/work/adrn/src/adrn/configure.zcml, line 27.2-27.32 ZopeXMLConfigurationError: File /home/reuleaux/work/adrn/src/adrn/browser/configure.zcml, line 40.2-40.27 ZopeXMLConfigurationError: File /home/reuleaux/work/adrn/src/adrn/browser/av/configure.zcml, line 14.2 UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 0: ordinal not in range(128) I get similar errors at runtime (when rendering the form) if I try to change the title of an existing button: class AdrEditForm(form.EditForm): ... buttons=form.EditForm.buttons # save changes buttons['apply'].title=u'Änderungen speichern' this gives me: Traceback (most recent call last): File /home/reuleaux/z3eggs/tmp-nK7Ng/zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/publish.py, line 133, in publish File /home/reuleaux/z3eggs/tmp1LrliP/zope.app.publication-3.4.0a1_2-py2.4.egg/zope/app/publication/zopepublication.py, line 167, in callObject File /home/reuleaux/z3eggs/tmp-nK7Ng/zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/publish.py, line 108, in mapply - __traceback_info__: security proxied z3c.pagelet.zcml.AdrEdit instance at 0xb6d1928c File /home/reuleaux/z3eggs/tmp-nK7Ng/zope.publisher-3.5.0a1.dev_r78838-py2.4.egg/zope/publisher/publish.py, line 114, in debug_call File /home/reuleaux/work/adrn/src/adrn/browser/views.py, line 636, in __call__ self.update(**kw) File /home/reuleaux/work/adrn/src/adrn/browser/views.py, line 692, in update self.form.update() File /home/reuleaux/work/adrn/src/adrn/browser/views.py, line 334, in update super(AdrEditForm, self).update() File /home/reuleaux/tmp/z3c.form/src/z3c/form/form.py, line 183, in update self.updateActions() File /home/reuleaux/tmp/z3c.form/src/z3c/form/form.py, line 179, in updateActions self.actions.update() File /home/reuleaux/tmp/z3c.form/src/z3c/form/button.py, line 229, in update buttonAction = zope.component.getMultiAdapter( File /home/reuleaux/z3eggs/tmpxWsYeR/zope.component-3.4.0a1-py2.4.egg/zope/component/_api.py, line 101, in getMultiAdapter File /home/reuleaux/z3eggs/tmpxWsYeR/zope.component-3.4.0a1-py2.4.egg/zope/component/_api.py, line 114, in queryMultiAdapter File /home/reuleaux/z3eggs/tmpxWsYeR/zope.component-3.4.0a1-py2.4.egg/zope/component/registry.py, line 206, in queryMultiAdapter File /home/reuleaux/z3eggs/tmpiBfeIG/zope.interface-3.4.0-py2.4-linux-i686.egg/zope/interface/adapter.py, line 482, in queryMultiAdapter File /home/reuleaux/tmp/z3c.form/src/z3c/form/button.py, line 191, in __init__ action.Action.__init__(self, request, field.title) File /home/reuleaux/tmp/z3c.form/src/z3c/form/action.py, line 60, in __init__ name = util.createId(title) File /home/reuleaux/tmp/z3c.form/src/z3c/form/util.py, line 33, in createId return name.encode('hex') File encodings/hex_codec.py, line 24, in hex_encode UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 0: ordinal not in range(128) Two points to note: * I don't want to introduce i18n just for the buttons @button.buttonAndHandler(_(u'Change')) My app is german only and if I was to introduce i18n I would still make german the primary language and English the second, i. e. I would still want @button.buttonAndHandler(_(u'Ändern')) * This caused me no problems in formlib, there I could do e.
Re: [Zope3-Users] z3c.form, checkboxes for Bool fields - thanks a lot, now: z3c.form egg from svn
Thanks again, works like a charm, i. e. both: * your tree / buildout config with link to z3c.form from svn * and the new checkbox.SingleCheckBoxFieldWidget -Andreas On Tue, Sep 04, 2007 at 10:40:32PM -0400, Stephan Richter wrote: On Tuesday 04 September 2007 21:13, Andreas Reuleaux wrote: Next question now: how do I tell zc.buildout to build an egg from svn for z3c.form? - I have tried this (adrn ist my application): My tree looks something like that: packages/ z3c.form/ -- svn://svn.zope.org/repos/main/z3c.form/trunk z3c.formui/ -- svn://svn.zope.org/repos/main/z3c.form/trunk myprojects/ z3c.form -- symlink to ../z3c.form In buildout.cfg of myproject, I have: [buildout] develop = . z3c.form Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training !DSPAM:46de72bc56542107185924! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form, style-attribute of TextWidget, TextAreaWidget
On Tue, Sep 04, 2007 at 02:50:05PM -0400, Stephan Richter wrote: Note that we usually solve the problem you are heaving by specifying the input element's id as the CSS selector: input#form-widgets-firstName { width: 105px; } got it Is there any particular reason why this style attribute was left out or is this just a bug? - The same for textarea_input.pt Bug. It is now fixed in the trunk for all widgets. and thanks for fixing -Andreas ___ 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 - thanks a lot, now: z3c.form egg from svn
On Tue, Sep 04, 2007 at 06:35:29PM -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. OK, thanks a lot. Next question now: how do I tell zc.buildout to build an egg from svn for z3c.form? - I have tried this (adrn ist my application): buildout.cfg ... find-links = http://download.zope.org/distribution/ svn://svn.zope.org/repos/main/z3c.form/trunk#egg=z3c.form-dev ... eggs = adrn z3c.form==dev ... setup.py ... install_requires = [... 'z3c.form==dev' ... ] However I get [EMAIL PROTECTED](~/work/adrn)$ ./bin/buildout Develop: '/home/reuleaux/work/adrn/.' Installing adrbuch. Download error: unknown url type: svn -- Some packages may not be found! Getting distribution for 'z3c.form==dev'. Installing z3c.form dev Caused installation of a distribution: z3c.form 1.6.0 with a different version. Got None. While: Installing adrbuch. Error: There is a version conflict. We already have: z3c.form 1.6.0 but adrn 0.1 requires 'z3c.form==dev'. [EMAIL PROTECTED](~/work/adrn)$ -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Still trying am to build an EditForm
Hi Florian, I have been playing with your example, try this: download http://user.cs.tu-berlin.de/~reuleaux/blogs.tgz unpack and cd into blogs edit buildout.cfg as you see fit: especially the eggs-directory should be changed, right now: /home/reuleaux/z3eggs $ python bootstrap.py $ ./bin/buildout $ ./bin/instance start|stop|restart|debug then goto: localhost:8080 you can e. g. add a folder there, say foo (but you don't have to) the use the My skin: http://localhost:8080/++skin++My/foo there you can add blog entries, edit them, see the list of all entries, there is some navigation bar on the left. Basically this is a mixture of * the addressbook-example of formdemo * your interface defs * Baiju's blog for zc.buildout example * some of my own stuff, that I learnt from z3c.form so far some points to note: * somewhere in a template I was having difficulties with widget/content - therefore changed to cntnt * there are some Makefiles in there that allow you to clean up - in the current folder with: make clean - recursively with: make rclean * the example really needs some cleanup - lot's of pkgs not needed - forms could certainly be used smarter: e g. I wanted a DisplayForm with a change button - I used form.Form however it works for me. hope this helps. -Andreas On Sun, Sep 02, 2007 at 09:39:56PM +0200, Florian Lindner wrote: Hello, I am still trying to build an EditForm using z3c.form. Since my previous thread is rather old I dare to open a new one. I've tried a number of variations and will post the one which is the closest to the example. This is the interface: class IBlogEntry(IContainer): Interface for blog entry objects. contains(IBlogComment) title = TextLine( title = _(uBlog entry title), description = _(uBlog entry title.), default = u, required = True) content = Text( title = _(uBlog entry content), description = _(uBlog entry content.), default = u, required = True) inputType = Choice( title = _(uType of input), description = _(uSpecify the input type), required = True, default = ureStructeredText, values = [ureStructeredText, uHTML] ) The view is configured like that: z3c:pagelet name=EditEntry.html for=..interfaces.IBlogEntry class=.views.EditEntry permission=Blog.EditEntry layer=Blog.interfaces.IBlogLayer / The code in .views.EditEntry is: class EditEntry(layout.FormLayoutSupport, form.EditForm): fields = field.Fields(IBlogEntry).select(title, content) The layer is registered like that: interface interface=.interfaces.IBlogLayer name=BlogSkin type=zope.publisher.interfaces.browser.IBrowserSkinType / and class IBlogLayer(IFormLayer, IPageletBrowserLayer): Demo browser layer using div-form layout template. Now I call the URL. http://localhost:8080/++skin++BlogSkin/Blog/2007_08_16_abc/EditEntry 2007_08_16_abc ist an BlogEntry object. Now there comes an ComponentLookupError. A server error occurred. up. Traceback (most recent call last): Module zope.publisher.publish, line 133, in publish result = publication.callObject(request, obj) Module zope.app.publication.zopepublication, line 167, in callObject return mapply(ob, request.getPositionalArguments(), request) Module zope.publisher.publish, line 108, in mapply return debug_call(obj, args) - __traceback_info__: security proxied z3c.pagelet.zcml.EditEntry instance at 0xa0248cc Module zope.publisher.publish, line 114, in debug_call return obj(*args) Module z3c.formui.layout, line 27, in __call__ ILayoutTemplate) Module zope.component._api, line 103, in getMultiAdapter raise ComponentLookupError(objects, interface, name) ComponentLookupError: ((z3c.pagelet.zcml.EditEntry object at 0xa0248cc, zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/++skin++BlogSkin/Blog/2007_08_16_abc/EditEntry.html), InterfaceClass z3c.template.interfaces.ILayoutTemplate, u'') I have also tried some variations of the above like not using z3c:pagelet but an normal page directive, registered it without an layer directive and so on. So please... whats wrong there? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:46db201184319549218874! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.form, checkboxes for Bool fields
In my interface I have Bool fields, say e. g. for invitation class IAdr(Interface) ... invitation = Bool( title=u'Invitation', description=u'Invitation?', required=False ) ... Now when rendering the following edit-form class AdrEditForm(form.EditForm): fields = field.Fields(IAdr) ... I get radio-boxes for invitation like so: (*) yes ( ) no (by the way: this can also been seen in z3c.formdemo on the All widgets page widgets.html) Well nice - after all this reflects the behaviour of boolean values: they can be either yes (True) or no (False). Actually I preferred formlibs behaviour of rendering checkboxes for Bools though, something like: [v] I. e. a single checkbox that can either be checked [v] or not [ ] should suffice for a boolean value. - This is shorter than the radio buttons and just as good. Now I was hoping that this was implemented in z3c.form.browser.checkbox already: class AdrEditForm(form.EditForm): fields = field.Fields(IAdr) def MyFieldWidget(field, req): return widget.FieldWidget(field, checkbox.CheckBoxWidget(req)) fields['invitation'].widgetFactory = MyFieldWidget However I get *two* checkboxes now [ ] yes [ ] no for the one boolean field invitation - that's not exactly what I was looking for: *one* checkbox should be enough for a Bool field - and what should happen by the way, if I check both boxes ([v] yes [v] no)? I think there should be an easy way to do this. This is very common after all. - Any hints? Have I overlooked something? -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.form, style-attribute of TextWidget, TextAreaWidget
Given a simple interface IPerson with some TextLine (Text) fields class IPerson(Interface): a person nachname = TextLine( title=uNachname, ... ) vorname = TextLine( title=uVorname, ... ) anrede = TextLine( title=uAnrede, ... ) sonst = Text( title=u'Sonstiges', ... ) I should be able to give the widgets some custom appearance by not only appending to their klass-Attribute (w.addClass()) but also by setting their style-Attribute (w.style) like this class PersonEditForm(subform.EditSubForm): fields=field.Fields(IPerson) prefix='person.edit' def updateWidgets(self): super(PersonEditForm, self).updateWidgets() sty={'anrede': u'width: 55px;', 'vorname': u'width: 105px;', 'nachname': u'width: 105px;', } for k in sty.keys(): w=self.widgets.get(k) w.style=sty[k] w.addClass(in) The widgets do have a style-Attribute after all and this used to work in formlib. - However this has no effect when rendering: input type=text id=person-edit-widgets-nachname name=person.edit.widgets.nachname class=textWidget textline-field in value=.../ ... There is just no style attribute. - I would expect something like: input type=text id=person-edit-widgets-nachname name=person.edit.widgets.nachname class=textWidget textline-field in style=width: 105px; value=... / Having a look at text_input.pt in my z3c.form egg shows why: style is just ignored there. If I add the style attribute there, everything works fine: [EMAIL PROTECTED](~/z3eggs/z3c.form-1.6.0-py2.4.egg/z3c/form/browser)$ diff -u text_input.pt.ORIG text_input.pt --- text_input.pt.ORIG 2007-08-30 01:05:52.0 +0200 +++ text_input.pt 2007-08-30 13:59:30.0 +0200 @@ -26,4 +26,5 @@ accesskey view/accesskey; onselect view/onselect; size view/size; - maxlength view/maxlength / + maxlength view/maxlength; + style view/style / [EMAIL PROTECTED](~/z3eggs/z3c.form-1.6.0-py2.4.egg/z3c/form/browser)$ Is there any particular reason why this style attribute was left out or is this just a bug? - The same for textarea_input.pt -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How do I get the value of security proxied attributes from a view template
On Fri, Aug 24, 2007 at 09:45:57PM +0800, Yuan HOng wrote: Hi, list, I am just trying to migrate a existing application from Zope2 to Zope3, and had to feel around for my ways to do things correctly. I have following view.pt snippet: span tal:replace=context/item_nameItem Name/span pspecification: span tal:replace=context/specification //p pPrice: span tal:replace=context/sales_price //p The template is registered like this: browser:page for=homemaster.item.interfaces.IItem name=index.html template=view.pt permission=zope.View / What I get is output looking this: 卡朗妮专供出口环保型虹吸式连体座便器(坑距300mm) specification: 720x370x630mm Price: security proxied decimal.Decimal instance at 0x899443c What does the last line mean? How can I get the numeric value for the item's price? I defined the three attributes of the item identically, why only the price is security proxied? Following is the interface definition: from zope.security.proxy import removeSecurityProxy price=removeSecurityProxy(proxiedPrice) -Andreas class IItem(ISQLAlchemyObjectContained): Information about an item item_name = zope.schema.TextLine( title=_(u'Item Name'), description=_(u'Name of the item'), required=True) specification = zope.schema.TextLine( title=_(u'Item Specification'), description=_(u'Specification of the item'), required=True) sales_price = zope.schema.Float( title=_(u'Sales Price'), description=_(u'Sales price of the item'), required=True) For your information, I am using z3c.zalchemy to retrieve the item object from RDB. Has it anything to do with the security proxy? Best Regards, -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.homemaster.cn !DSPAM:46cef428299004360239799! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:46cef428299004360239799! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] z3c.formdemo, problems with lxml
I am just following the very simple instructions to install z3c.formdemo from zc.buildout $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/trunk formdemo $ cd formdemo $ python bootstrap.py $ ./bin/buildout -v ...lot's of eggs are downloaded, but when it comes to the lxml egg, I get tons of errors - only the last lines shown below - any hints? -Andreas ... src/lxml/etree.c:50771: error: ��struct __pyx_vtabstruct_5etree__FileParserContext�� has no member named ��_createParserInput�� src/lxml/etree.c:50771: error: ��__pyx_f_5etree_18_FileParserContext__createParserInput�� undeclared (first use in this function) src/lxml/etree.c:50772: error: ��struct __pyx_vtabstruct_5etree__FileParserContext�� has no member named ��_readDoc�� src/lxml/etree.c:50772: error: ��__pyx_f_5etree_18_FileParserContext__readDoc�� undeclared (first use in this function) src/lxml/etree.c:50773: error: ��struct __pyx_vtabstruct_5etree__FileParserContext�� has no member named ��_readDtd?� src/lxml/etree.c:50773: error: ��__pyx_f_5etree_18_FileParserContext__readDtd�� undeclared (first use in this function) src/lxml/etree.c:50774: error: ��struct __pyx_vtabstruct_5etree__FileParserContext�� has no member named ��copyToBuffer�� src/lxml/etree.c:50802: error: ��struct __pyx_vtabstruct_5etree__FilelikeWriter�� has no member named ��_createOutputBuffer�� src/lxml/etree.c:50802: error: ��__pyx_f_5etree_15_FilelikeWriter__createOutputBuffer�� undeclared (first use in this function) src/lxml/etree.c:50803: error: ��struct __pyx_vtabstruct_5etree__FilelikeWriter�� has no member named ��write�� src/lxml/etree.c:50804: error: ��struct __pyx_vtabstruct_5etree__FilelikeWriter�� has no member named ��close�� src/lxml/etree.c:51287: error: ��xmlParserVersion�� undeclared (first use in this function) src/lxml/etree.c:51351: error: ��LIBXML_VERSION�� undeclared (first use in this function) src/lxml/etree.c:51855: error: ��__pyx_v_5etree___DEFAULT_ENTITY_LOADER�� undeclared (first use in this function) src/lxml/etree.c:51858: error: ��__pyx_f_5etree__local_resolver�� undeclared (first use in this function) src/lxml/etree.c:51876: error: ��XML_PARSE_NOENT�� undeclared (first use in this function) src/lxml/etree.c:51876: error: ��XML_PARSE_NOCDATA�� undeclared (first use in this function) src/lxml/etree.c:51876: error: invalid operands to binary | src/lxml/etree.c:51876: error: invalid operands to binary | src/lxml/etree.c:52227: error: ��LIBXSLT_VERSION�� undeclared (first use in this function) src/lxml/etree.c:52232: error: ��xsltLibxsltVersion�� undeclared (first use in this function) src/lxml/etree.c:52237: error: ��__pyx_v_5etree_XSLT_DOC_DEFAULT_LOADER�� undeclared (first use in this function) src/lxml/etree.c:52237: error: ��xsltDocDefaultLoader�� undeclared (first use in this function) src/lxml/etree.c:52240: error: ��__pyx_f_5etree__xslt_doc_loader�� undeclared (first use in this function) error: Setup script exited with error: command 'gcc' failed with exit status 1 An error occured when trying to install lxml 1.3.3.Look above this message for any errors thatwere output by easy_install. While: Installing test. Getting distribution for 'lxml'. Error: Couldn't install: lxml 1.3.3 [EMAIL PROTECTED](~/tmp/formdemo)$ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Cache values must be persistent objects. - ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg
The example below (contacts) works fine for me with a recent svn checkout of the 3.4 branch, i e svn co svn://svn.zope.org/repos/main/Zope3/branches/3.4 z3 but I get errors with a recent eggs installation via zc.buildout (when trying to edit and save a contact, see below) ... File /home/reuleaux/z3eggs/tmp17mUe4/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py, line 58 3, in _commit File /home/reuleaux/z3eggs/tmp17mUe4/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py, line 63 5, in _store_objects TypeError: Cache values must be persistent objects. It seems other people where having similar troubles, see e. g. http://www.nabble.com/Problems-with-ZODB3-3.9.0_dev_r77011-t4109664.html however it is not obvious to me how to exactly apply the solutions proposed there to my code - there is no external file (like an image) involved in my code. The example is not to long, however it is not trivial: uses formlib, an object in its schema, object widgets, object widget dispatcher etc. - I have therefore included the complete example. - for convenience: I have also put it online (my old university account) $ wget -nd http://user.cs.tu-berlin.de/~reuleaux/contacts.tgz $ tar xvpzf contacts.tgz $ cd contacts edit buildout.cfg as you see fit, you might for example change the eggs-directory maybe adjust the mngr user/passwd in src/contacts/app.zcml $ python bootstrap $ ./bin/buildout $ ./bin/instance start usage / steps to reproduce: go to http://localhost:8080 log in as mngr and add some contacts - that works fine now edit such a contact (say I have given it a name rx) http://localhost:8080/rx/edit and try to save it: boom! I am aware that object widgets are kind of superseeded with the advent of z3c.form - and I really want to go in that direction but for the time being my programming would be much more relaxed if I got this example working, I could really need a helping hand here, thanks. -Andreas interfaces.py from zope.interface import Interface from zope.schema import TextLine, Object class IAddr(Interface): an address. street = TextLine( title=ustreet, description=uthe street, required=False, missing_value=u'' ) city = TextLine( title=ucity, description=uthe city, required=False, missing_value=u'' ) zipcode = TextLine( title=uzip, description=uthe zip code, required=False, missing_value=u'' ) class IContact(Interface): a contact name = TextLine( title=uname, description=uthe name, required=False, missing_value=u'' ) firstname = TextLine( title=ufirstname, description=uthe firstname, required=False, missing_value=u'' ) addr=Object( title=u'address', description=u'the address', required = False, schema=IAddr) addr.py from zope.interface import implements from interfaces import IAddr from zope.schema.fieldproperty import FieldProperty from persistent import Persistent class Addr(Persistent): Eine Addr. implements(IAddr) street = FieldProperty(IAddr['street']) city = FieldProperty(IAddr['city']) zipcode = FieldProperty(IAddr['zipcode']) def __init__(self, street=u'', city=u'', zipcode=u'', titel=u'', geb=u'', fkt=u''): self.street=street self.city=city self.zipcode=zipcode contact.py from zope.interface import implements from interfaces import IContact from zope.schema.fieldproperty import FieldProperty from persistent import Persistent from zope.security.proxy import removeSecurityProxy # from zope.app.container.contained import Contained # class Contact(Contained, Persistent): class Contact(Persistent): a contact. implements(IContact) __name__ = __parent__ = None name = FieldProperty(IContact['name']) firstname=FieldProperty(IContact['firstname']) addr = FieldProperty(IContact['addr']) def __init__(self, name=u'', firstname=u'', addr=None, ): self.name=name self.firstname=firstname self.addr=addr # def __getstate__(self): # s=Persistent.__getstate__(self) #s['addr']=removeSecurityProxy(self.addr) #return s views.py from zope.formlib import form, namedtemplate from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from interfaces import IContact from contact import
Re: [Zope3-Users] zc.buildout beginner's question
Never mind: I put some Makefiles with recursive clean targets in mydemo. Also I have found z3.log in parts/instance. Thanks, Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] zc.buildout beginner's question
I am aware that a lot of fancy stuff can be done with zc.buildout, however I am just starting... I found Benji's blogs a good entry point: [1] http://baijum81.livejournal.com/19795.html [2] http://baijum81.livejournal.com/20551.html I got z3hello running - hey, that was not to hard - and decided to use that as a starting point / playground for my own experiments: mydemo, just doing some trivial changes: * rename z3hello to mydemo throughout * removing the .svn subdirectories (I am not checking anything in, nor do I want svn to get confused should I later check in to somewhere) * remove the urls: neither do I want my demo to be registered in pypi (yet) nor somehow uploaded to Benjis place * etc. So I now have my own little buildout mydemo to play with. Cautious as I am I save that as a Skeleton $ cp -rp mydemo mydemo-skeleton i. e. *before* running the following cmds in mydemo $ python bootstrap.py $ /bin/buildout -N $ /bin/instance start no I can go to: http://localhost:8080/mydemo And the page says Hello Now being a programmer I make only a little change to make my page say Hello from Rx and save that, I could go own from here making changes till I got a full blown application. However at this point I want to make sure I can get back to the original mydemo layout (before bootstrapping/starting) i. e. I want some way to save my work in a directory say mydemo1 that is nearly identical to the original: $ diff -f mydemo-skeleton mydemo1 should only reflect my change: Hello - Hello from Rx roughly make clean if I was using make some ideas: * $ ./bin/buildout setup . sdist somehow produces an egg in dist/mydemo-0.1.tar.gz but that has not the other files: bootstrap.py, bootstrap.py, setup.cfg * I saw fancy uninstall recipes in Jim's slides - do I really those? http://svn.zope.org/zc.buildout/trunk/doc/tutorial.txt?rev=76281view=auto pdf: http://www.zope.de/redaktion/dzug/tagung/potsdam-2007/folien/introduction-to-zc-buildout.pdf/download * or uninstall_service in entry points - - not sure yet what entry points are good for * there should be some easy way to clean up? Totally different question: When using a zope from svn I could watch the log file z3.log $ tail -f z3.log while I was (re)starting/stopping the daemon that was convenient What needs to be done to make Benji's z3hello log to some file? -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zc.buildout beginner's question
$ diff -f mydemo-skeleton mydemo1 should only reflect my change: Hello - Hello from Rx my typo: should read $ diff -r ... i. e. recursive diff ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zc.buildout beginner's question
I found Benji's blogs a good entry point: Baiju's blog i. e. - well, it's getting late ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Guidance on accessing MySQL db.
Admittedly there has not been much documentation of connecting Zope 3 to a relational database like MySQL. - Personally I don't have much experience either. Some hints anyway: The preferred way is to use an ORM * either SQLObject - then use sqlos http://codespeak.net/z3/sqlos/ * or sqlalchemy - then you have two choices - the older one: http://svn.zope.org/z3c.zalchemy/trunk demos: z3c.zalchemy/trunk/src/z3c/zalchemy/demo - the younger one: http://svn.zope.org/z3c.sqlalchemy/trunk/ (I would go for z3c.sqlalchemy) Also have a look at http://svn.zope.org/mysqldbda/trunk/ for a connection without an ORM (not sure in what shape that code is) Maybe the authors of those packages can give better advice. -Andreas On Fri, Mar 30, 2007 at 03:32:16PM -0700, Rich C wrote: Hello all, I've just started using Zope 3 and am having some difficulty finding examples on a good way to access a MySQL database. For the moment, I'd just like to be able to read from the database and display it in a web page with decent formatting. I've read examples from Zope 2 where they used a DTML page that called a ZSQL method such as the following: dtml-in river_info dtml-var river_id dtml-var river_name /dtml-in ZSQL method would then contain: SELECT river_id, river_name FROM river_info In Zope 3, I only see an option to add a SQL script which I'm pretty sure is not the same thing as a ZSQL method since I've copied the above into a SQL script and Testing the script by itself does in fact read from the MySQL database, but I can not access the SQL script from a DTML page. I get the following error: KeyError A server error occurred. So, some very basic questions : What is the suggested way to access a MySQL database from Zope 3. Should I even be creating DTML scripts, my understanding was that there are better ways of doing things than with DTML in Zope 3. Basically, I just want to be able to customize the displaying of whats in the database. On this list, there was a posting of someone creating a content type to access the database. Maybe this is what I need to be doing. Seems like a lot of overhead, as compared to Zope 2. Here is a link to that thread: http://mail.zope.org/pipermail/zope3-users/2006-February/002476.html Basically, I'm looking for guidance/suggestions on the right way to go about doing this. Any help would be greatly appreciated. Thanks, Rich Bored stiff? Loosen up... Download and play hundreds of games for free on Yahoo! Games. http://games.yahoo.com/games/front ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:460d9c8b229491637432971! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zope 3 book - is it still meaningful ?
Yes, it is still a very valuable text, Stephan just has plenty of other things to do and hasn't found the time to update the book (he can tell you better if and when there will be an update). But this is a general problem of computer texts: It takes some effort to keep them up to date. Note that this is still Stephans book, not a book written by the Zope 3 community (don't know if he would be interested in having more people maintain the book). You might want to read Stephans book in parallel with Philipps book and find out which suits you better in which area. (Note that Philipps is preparing a second edition of his book) On Sat, Aug 26, 2006 at 12:07:56AM +0200, catonano wrote: Hello people, I'm trying to follow the Zope 3, precisely the part that you can find at http://dev.zope.org/Zope3/Zope3Book/contentobject.html. it shows how to create new content type components ( a message board type and a message type) All the source code files are downloadable from the svn, so you can try , following the instructions in the book. The book is quite old ! In the svn I see it's been edited last time in 2004 ! In chapter 13, paragraph 6, there's this sentence: ... There is a script called test.py that will run all or only specified tests for you. To run the test against your implementation, execute the following line from the Zope 3 root directory: 1 python2.3 test.py -vpu --dir src/book/messageboard ... Well, is there a test.py file ? I can't find it ! ...from the Zope 3 root directory means: $ svn co svn://svn.zope.org/repos/main/Zope3/trunk z3 $ cd z3 $ python2.4 ./test.py ... I. e. test.py is in the checkout of Zope 3, not of the example -Andreas Also in the svn there's so much material that isn't regarded at all in the book text ! Is that text still valuable ? Or is it obsolete and meaningless, at now ? Thanks so much Bye Catonano ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:44ef776c193711660682232! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3 SSL
I have Zope 3 running behind Apache+SSL but according to a discussion on this list in June Zope 3 itself should be capable of understanding SSL if pyopenssl is installed (haven't tried it myself), have a look at the threads starting at http://mail.zope.org/pipermail/zope3-users/2006-June/003725.html and http://mail.zope.org/pipermail/zope3-users/2006-June/003770.html -Andreas On Wed, Aug 23, 2006 at 07:57:27PM +, Stéphane Brault wrote: Hi, I need to run my site with SSL. I don't know how to use SSL with Zope 3 or if I should run zope behind apache 2, and if so how. Any hint ? Thanks, Stéphane ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:44ecbb11129261804284693! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] state of pure Zope 3 CMSs?
I wonder what is that state of pure Zope 3 CMSs? - Cubic and z3ecm come to mind, see below. I am aware that sytems like *Plone* offer everything you can imagine for serious CMS development. But being based on Zope 2 (and just slowly moving towards Zope 3 by means of Five) they also carry a lot of baggage with them: * Say you want to develop a Plone product based on Zope 3 (Five): You effectively have to master Zope 2, Plone and Zope 3. * On my debian system (after installation of plone-site) du -h /var/lib/zope2.8/instance/plone-site/Products/ gives me: 19M - that's a lot. Many portals start out as some small projects and might not need all the fancy stuff. Being small in code and therefore easily manageble might be more important. Besides: if they where solely based on Zope 3, adding more stuff to them should be easier anyway (by means of adapters e. g.). Cubic and z3ecm come to my mind - are there more? Cubic - I was able to check it out into my zope 3 (svn trunk) tree with svn co http://svn.amazesolutions.com/zope3/cubic/trunk cubic And after replacing some MessageIdFactory occurences with MessageFactory I was able to run it, but actually adding a Cubic portal resulted in an error: File /home/reuleaux/z3/src/zope/app/keyreference/persistent.py, line 41, in __init__ raise zope.app.keyreference.interfaces.NotYet(object) The former home page http://opensource.amazesolutions.com/projects/zope3/cubic doesn't exist any more. I didn't find a mailing list. Was it ever meant to be usable for some small portal sites. Or was it just a toy project, some experiment? z3ecm - I am aware that this is an ambitious joint effort of Nuxeo and Infrae to create the infrastructure of a next generation CMS. But looking at the web site http://www.z3lab.org/ I could find some fancy video animations, but no tutorial/introduction/readme.txt/install.txt how to install and how to procede next. Well the About page (http://www.z3lab.org/sections/about) gives an excuse (...So don't expect to find here anything usable from a user point of view...) and I saw that in the last entry on the mailing list archive http://lists.nuxeo.com/pipermail/z3lab/2006-August/000991.html someone is asking the same question: Can someone help get me to a point where I can play with z3ecm? On the same About-page they welcome everybody to work on the project - Honestly, my interest in a project that I cannot even install is not very high. I might even misunderstand z3ecm altogether: Will there ever be a CMS based on zope3 and z3ecm only. Or will it for years to come just be a bridge techique: Zope2 + Five(Zope 3) + Z3ecm + Silva/CPS? Well I guess I should ask this on the z3ecm mailing list. - but I thought the idea of having a pure Zope 3 CMS was of general interest. -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Trouble with browser sign on
Just try again, I have no problems with encrypted passwords (I am however using SHA-passwords, i. e. option 3). As the result of your makeinstance call with say with instance directory foo you get a principals file foo/etc/principals.zcml There you will find an entry matching your username/password combination, something like principal id=zope.manager title=Manager login=myusername password=mypasswd / You can comment out this entry with !-- principal id=zope.manager title=Manager login=myusername password=mypasswd / -- and replace it with a different entry, try calling foo/bin/zpasswd answer the question, you will get a new principal .../ that you can cut/copypaste to your principals.zcml file, then just restart Zope -Andreas On Thu, Jun 22, 2006 at 06:24:04PM -0400, Daniel Roberson wrote: After installing zope and python, I then changed to scripts directory. I then ran mkzopeinstance and created the instance. I had to tell it the instance directory to create and a username and password. It then asked if I wanted the password in text or encrypted format. I selected number 2 encrypted option. When I when to the browser the entered the http://localhost:8080/manage command it popped open the username and password dialog box. I enter the correct username and password but it would not log me on. I repeated the whole mkzopeinstance process but this time select a plain text password option number 1. Then I was able to log in. What do I need to do to be able to use an encrypted password with a browser !DSPAM:449b1bbe311396561975923! begin:vcard fn:Daniel Roberson n:Roberson;Daniel org:Robert Daniels, LLC adr;dom:;;6514 Hillsboro Lane;Fort Wayne;Indiana;46835 email;internet:[EMAIL PROTECTED] title:Founder and Managing Director tel;work:260.486.1860 tel;fax:260.486.1860 tel;cell:260.750.3407 x-mozilla-html:TRUE url:http://www.robertdaniels.net version:2.1 end:vcard ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:449b1bbe311396561975923! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] SFTP , SSL
SSL (and therefore HTTPS, SFTP) is supporterd but not yet enabled, from the 3.2.0 release notes (http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope320): Most Important Changes Since 3.1 * The ZServer? has been replaced with the Twisted server. The Twisted server supports all that the ZServer? supporting has well has HTTP over SSL natively and SFTP ***(disabled for now because of error handling problems)*** So you will have to wait - other people are interested in SSL, too (I remember to have seen a discussion on on one of the lists zope3-users or -dev, I just don't remember where at the moment), but it seems the problem was not considered of a high priority for most of the developers - you can of course use SSL by running Zope behind Apache. I never heard that Zope itself was offering SSH but I might be wrong. -Andreas On Fri, Jun 16, 2006 at 03:30:11PM -0500, Mike Emerick wrote: I have been trying to get the SSL server and the SSH server running with Zope 3. When I uncomment ssh server in the zope.conf file I get the following. Traceback (most recent call last): File ./runzope, line 48, in ? run() File ./runzope, line 44, in run main([-C, CONFIG_FILE] + sys.argv[1:]) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/main.py, line 74, in main service = setup(load_options(args)) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/main.py, line 151, in setup service = server.create(db) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/ server.py, line 204, in create servertype = zapi.getUtility(IServerType, self.type) File /usr/local/Zope-3.2.1/lib/python/zope/component/ __init__.py, line 257, in getUtility raise ComponentLookupError(interface, name) zope.component.interfaces.ComponentLookupError: (InterfaceClass zope.app.twisted.interfaces.IServerType, 'SFTP') I have looked every all over for a solution. I can confirm this on Suse Linux 10 and Mac OS 10.4 and 10.3. Has anyone seen this. SSL gives a similar error just replace the SFTP with SSL. Thanks, Mike ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:4493219a117902252880176! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] SFTP , SSL
I just read Davids answer - interesting - and I am a bit confused: So HTTPS seems to be working now, supported and enabled? - Is this the official status for SSL now? Or is it just working on Mac OS X, is pyopenssl officially required - if so, then I think this should be stated somewhere in the release notes. I must admit it has been a while that I tried HTTPS (with no succes at that time) and the (disabled for now because of error handling problems) that I found in the release notes was just the explanation I found convincing at that time. -Andreas On Fri, Jun 16, 2006 at 06:53:02PM -0300, David Pratt wrote: Hi Mike. Can you confirm you have pyopenssl-0.6 installed and proper paths in your config. It should look like this in your config if you are using the default files supplied. sslserver type HTTPS address 8443 privatekeypath $CONFDIR/server.pem certificatepath $CONFDIR/server.pem /sslserver Just to let you know I am running on mac and everything is fine for me. I am on OSX 10.3. Regards, David Mike Emerick wrote: I have been trying to get the SSL server and the SSH server running with Zope 3. When I uncomment ssh server in the zope.conf file I get the following. Traceback (most recent call last): File ./runzope, line 48, in ? run() File ./runzope, line 44, in run main([-C, CONFIG_FILE] + sys.argv[1:]) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/main.py, line 74, in main service = setup(load_options(args)) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/main.py, line 151, in setup service = server.create(db) File /usr/local/Zope-3.2.1/lib/python/zope/app/twisted/server.py, line 204, in create servertype = zapi.getUtility(IServerType, self.type) File /usr/local/Zope-3.2.1/lib/python/zope/component/__init__.py, line 257, in getUtility raise ComponentLookupError(interface, name) zope.component.interfaces.ComponentLookupError: (InterfaceClass zope.app.twisted.interfaces.IServerType, 'SFTP') I have looked every all over for a solution. I can confirm this on Suse Linux 10 and Mac OS 10.4 and 10.3. Has anyone seen this. SSL gives a similar error just replace the SFTP with SSL. Thanks, Mike___ 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 !DSPAM:44932990119481209560715! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] binding z3 to localhost only (security) / xmlrpc via https
If have successfully setup zope3 behind a ssl-enabled apache2 (apache and zope3 both running on the same host mousehouse) using ProxyPass and ProxyPassReverse directives as described in Philipps book in chapter 17, example 17.3.1, i. e. I can reach zope with https://mousehouse/... Now I want to bind zope3 to localhost only, in order to make sure it can *only* be reached with https://mousehouse/..., *not* with http://mousehouse:8080 any more. This should be possible (and is mentioned in Philipps book on page 303, Only binding it to localhost ensures that noone from the outside gains access to Zope directly). I just haven't figured out how to do this, maybe I have overlooked something. How do I bind it to localhost only? A related but different question: I have some xmlrpc scripts that work in a fashion like this import xmlrpclib URL='http://user:[EMAIL PROTECTED]:8080/somefolder' book=xmlrpclib.ServerProxy(URL, allow_none=True) [do stuff with book] They don't work any more with URL='https://user:[EMAIL PROTECTED]:8080/somefolder' Is there anything special needed to make xmlrpc scripts work with zope through ssl+apache? Thanks in advance. -Andreas ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] binding z3 to localhost only (security) / xmlrpc via https
Please ignore the second question, my fault: xmlrpc works fine via apache+ssl, just had to leave out the :8080 URL='https://user:[EMAIL PROTECTED]/somefolder' On Sat, May 06, 2006 at 11:09:50PM +0200, Andreas Reuleaux wrote: ... A related but different question: I have some xmlrpc scripts that work in a fashion like this import xmlrpclib URL='http://user:[EMAIL PROTECTED]:8080/somefolder' book=xmlrpclib.ServerProxy(URL, allow_none=True) [do stuff with book] They don't work any more with URL='https://user:[EMAIL PROTECTED]:8080/somefolder' Is there anything special needed to make xmlrpc scripts work with zope through ssl+apache? ... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] binding z3 to localhost only (security) / xmlrpc via https
Thanks a lot, that was it. -Andreas On Sat, May 06, 2006 at 11:40:59PM +0200, Igor Stroh wrote: ... Adjust the server section of your zope.conf accordigly: server type HTTP address 127.0.0.1:8080 /server Cheers, Igor ... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ZODB - root and transaction
I can't really point at your problem, sorry. But I have a similar script to fill my ZODB which works for me. You might want to try to experiment with this / modify your script ... #!/usr/bin/env python2.4 # -*- coding: utf-8 -*- from ZODB import FileStorage, DB import transaction # ... fs = FileStorage.FileStorage('/home/reuleaux/z3/Data.fs') db = DB(fs) con=db.open() root = con.root() app=root['Application'] bookfolder=app['bookfolder'] # ... bookfolder[name]=b transaction.commit() db.close() -Andreas On Wed, Apr 05, 2006 at 10:33:55AM +, Reinhold Strobl wrote: Hi, I have got two problems, which are related: 1. How do get a reference to the root object of the ZODB everywhere? I mean I have found a solution like something: db = zapi.getUtility(IDatabase) conn = db.open() root = conn.root() root['123'] = newbook But it does not acutally store the object in the database. I try to commit it, but conn.getTransaction.commit() won't work. I search instead for get_transaction(), but I didn't found it in Python 's lib directory. So, how do I save it??? 2. How do I get (the current) transaction? Thanks a lot in advance! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:4433b55b83084275821350! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] practical example of migrating from services to utilities
On Mon, Aug 08, 2005 at 01:57:21PM -0600, Duncan McGreggor wrote: Hey all, I just wanted to check to make sure I was doing this right, and if so, provide a resource that would turn up on subsequent googling. This example involves the getting menus items with the getService/getUtility functions and is taken from Philip's worldcookery example code. Here's the pertinent zcml (worldcookery/browser/configure.zcml): browser:menu id=alternate_views title=Menu containing a list of alternative views for an object / browser:addMenuItem title=[label-recipe] Recipe class=worldcookery.recipe.Recipe permission=worldcookery.EditRecipes view=AddRecipe.html / Here's the original code (worldcookery/browser/recipe.py): def alternateViews(self): menu_service = zapi.getService(servicenames.BrowserMenu) menu_id = 'alternate_views' return menu_service.getMenu(menu_id, self.context, self.request) Here's the modified example that I'd want to check if I am doing correctly: def alternateViews(self): browser_menu = zapi.getUtility(IBrowserMenu, 'alternate_views') return browser_menu.getMenuItems(self.context, self.request) Am I doing this properly? ... I haven't tried your solution zapi.getUtility(IBrowserMenu, 'alternate_views') (I doubt it works) but I had the same problem some time ago, and Philipp had pointed out to me that there are simpler solutions now - both of them worked fine for me (his original e-mail to me in German below, the English translation is mine): There is no global browser menu service available any more. And there is no corresponding utility, as for most of the other services. Menu items are simply adapters in Zope 3.1. The helper function getMenu from zope.app.publisher.browser.menu is handy for the lookup. The method alternateViews() from example 12.3.3 can now be written as def alternateViews(self): menu_id = 'alternate_views' return getMenu(menu_id, self.context, self.request) Besides that there is an even easier to use view view_get_menu (that Philip regrets to not have mentioned in his book). Example 12.3.4 could be written as li tal:repeat=item context/@@view_get_menu/alternate_views ... /li This worked in Zope 3.0 already (and has not changed in Zope 3.1) It can also be recommended as there is no requirement for an additional method in a view class. Regards, Andreas (from Philips E-mail:) Der Global Browser Menu Service ist komplett weggefallen. Eine Entsprechung als Utility, wie das mit den meisten anderen Services der Fall ist, gibt ebenfalls nicht. Menü-Einträge sind unter Zope 3.1 einfache Adapter. Die Hilfsfunktion getMenu aus dem zope.app.publisher.browser.menu Modul erleichtert das Lookup. Die Methode alternateViews() in Beispiel 12.3.3 könnte nun folgendermaßen implementiert werden: def alternateViews(self): menu_id = 'alternate_views' return getMenu(menu_id, self.context, self.request) Es gibt übrigens auch den etwas leichter zu bedienden View view_get_menu, den ich leider vergessen habe zu behandeln. So könnte Beispiel 12.3.4 ab Zeile 20 auch heißen: li tal:repeat=item context/@@view_get_menu/alternate_views ... /li Diese Methode ist transparent gegenüber den Änderungen von X3.0 zu 3.1 und insofern auch empfehlenswert, allein schon weil eine zusätzliche Methode in der View-Klasse entfällt. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] missing_value for Text fields
some low resolution screen shot added attachment: boom.jpg ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] missing_value for Text fields
Submitted now as Issue 421, missing_values for Text fields don't work - Andreas On Wed, Jun 29, 2005 at 09:32:53AM -0400, Fred Drake wrote: You need to be logged in to successfully submit a bug report. -Fred -- Fred L. Drake, Jr.fdrake at gmail.com Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users !DSPAM:42c2b39532011404515798! ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] object widgets, persistency
To answer my own question - just for the record, in case someone is having the same difficulties - I found redefining __getstate__ in Family solved my problem: ... from zope.security.proxy import removeSecurityProxy class Family(Persistent): ... def __getstate__(self): s=Persistent.__getstate__(self) s['mother']=removeSecurityProxy(self.mother) s['father']=removeSecurityProxy(self.father) return s On Mon, Apr 25, 2005 at 11:42:25PM +0200, Andreas Reuleaux wrote: ... Then I tried to make Family persistent, i. e. from persistent import Persistent class Family(Persistent): ... and I learned subobjects should be persistent, too from persistent import Persistent class Person(Persistent) ... Now when I change family objects in the editform I can do so safely with foo and bar, but changing Mother's or Father's name results in an error: UnpickleableError: Cannot pickle type 'zope.security._proxy._Proxy' objects The complete error log is shown below, too. - It seems to me that because one has to declare view- (rs. edit-) permissions for Person require permission=zope.View interface=.iperson.IPerson / Person is wrapped in a security proxy and therefore family can't be saved (pickeled) any more. - Any idea how to solve this? I don't have this problem if I only make Person persistent (not Family) but of course then I am losing changes to the family attributes foo and bar. ... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users