Re: [Zope3-Users] Getting view result from Python
Le mercredi 27 juin 2007 à 20:17 +0300, Marius Gedminas a écrit : On Wed, Jun 27, 2007 at 04:59:07PM +0200, Thierry Florac wrote: Le mercredi 27 juin 2007 à 14:31 +0200, Christophe Combelles a écrit : Thierry Florac a écrit : I'd like to get a view output from some Python code. Actually, I don't have any problem if I use a page template with a simple tal:x content=structure context/@@viewname / expression and return self.template() in Python. But it should certainly be cleaner and less expensive to get view output directly from Python code, which I don't actually manage to do... It depends on what you call a view, if this is a BrowserPage, you have a __call__ method that returns the output. so just call your view(). If this is a BrowserView, there is no __call__ because a BrowserView is not intended to be published as is. But you can have any method that returns HTML. If you use getMultiAdapter to get the view, all these differences are hidden and you can call the view to get its output. If this is a Viewlet or a ContentProvider, there is a render method that returns the output. (provided you first call the update method) Then it's not really a view, is it? ;-) In fact it's a little bit more complicated... What I have at first is a BrowserPage view, which is generally called from a page template with context/@@viewname syntax, without any problem. But I need also to be able to get the same view output from a JSON call, so that I can update a little bit of HTML code dynamically. I don't have any problem when defining a template with the same syntax. But if I call in python : view = zapi.getMultiAdapter((myContext,myRequest), Interface, name=u'viewname') This should work. You don't have to pass Interface explicitly, by the way, view = getMultiAdapter((context, request), name='...') will work as well. I receive an error message : __init__() takes at least 3 arguments (1 given) I don't believe you :-) Can you show the full traceback? getMultiAdapter definitely passes the context tuple to the adapter's __init__. There must be some other piece of code that fails for you. So zapi.getMultiAdapter creates the view, but how can I initialize it with it's required parameters (context and request) ? getMultiAdapter does that. I speak from personal experience. Whoops ! I'm really sorry but I think I made a stupid mistake in my zapi.getMultiAdapter() call, because I used a custom request as parameter instead of the initial request I received in my JSON MethodPublisher subclass ; that's probably because of several tests I made to get things working as I need... :-( Really sorry again, but now it works perfectly... Thierry Florac -- Chef de projet intranet/internet Office National des Forêts - Département Informatique 2, Avenue de Saint-Mandé 75570 PARIS Cedex 12 Mél : [EMAIL PROTECTED] Tél. : +33 01.40.19.59.64 Fax. : +33 01.40.19.59.85 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: [Zope] z3c.form 1.3.0, z3c.formui
In my case, I use archgenxml very often which now requires a Zope 3.3 installation or a Zope 2.10 one, so I have this set in my bashrc. Also, when trying to access Zope 3 libraries from python console, since I am still in Zope 3.3, there are no eggs available for that installation so I need to set my PYTHONPATH to test things. IOW, specific things. So I believe it is common to have this unset. There is 'workingenv' tool that allows you to have distinct environments. Maybe I'm missing something obvious... but how should I install z3c.form if I want to use this with my existing zope instance. I mean I have zope 3.3.1, downloaded from zope.org in tar.gz file and installed in my system. If I execute easy_install z3c.form then i get a lot of eggs that I don't want because I already have my zope and new eggs seems to be from zope 3.4 alpha version, eg.: (...) zope.app.i18n-3.4.0a1-py2.4.egg zope.app.http-3.4.0a1 (...) Should I manually download just necessary eggs? What is preffered way to do it? -- Maciej Wisniowski ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form 1.3.0, z3c.formui 1.0.1, and z3c.formdemo 1.1.0 released!
Again for the curious and impatient ... --- We have added two more demos: * An Address Book implements a non-trivial example of an address book, including multiple addresses and E-mails. It demonstrates the use of sub-forms, writing custom widgets and composite content. This demo is really impressive! * An SQL Message demo reimplemnets the simple Hello World! demo only using queries to the Gadfly database. The example adds to the original demo by also providing a message overview screen, since the ZMI is not helpful for pure SQL data. Thanks for this one :) -- Maciej Wisniowski ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: [Zope] z3c.form 1.3.0, z3c.formui
On Thursday 28 June 2007 08:45, Maciej Wisniowski wrote: Maybe I'm missing something obvious... but how should I install z3c.form if I want to use this with my existing zope instance. There are several ways of doing it based on your religion of distutils. I mean I have zope 3.3.1, downloaded from zope.org in tar.gz file and installed in my system. If I execute easy_install z3c.form then i get a lot of eggs that I don't want because I already have my zope and new eggs seems to be from zope 3.4 alpha version, eg.: (...) zope.app.i18n-3.4.0a1-py2.4.egg zope.app.http-3.4.0a1 (...) Right, the Zope 3 releases are not eggified yet. Should I manually download just necessary eggs? That would be the easiest. Download the tar.gz file from the cheeseshop, extract it and then copy or link the source to the correct location. What is preffered way to do it? Eventually, the preferred way will be to build applications using only eggs, like I did in z3c.formdemo. This process, however, is poorly documented at this point and requires significant effort on your side to study how buildout and setuptools work. So for now, copying the code to the correct location is okay. You can also always use checkouts as well, of course. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users