=== abentley1 is now known as abentley [19:54] when using context/@@+fragment, is there a nice way to pass GET or POST variables to +fragment ? === rockstar is now known as Guest38735 === rockstar` is now known as rockstar [20:17] adiroiban: we often add a initial_values property to the view that will provide a dict of sane values for the missing parameters [20:17] * sinzui looks for example [20:20] adiroiban: LaunchpadFormView sets the missing params from the initial_values dict as is done in lp/registry/browser/announcement.py [20:21] sinzui: thanks. I'll take a look [20:30] sinzui: the current view is just a LaunchpadView. I have something realy simple, and I don't want to make it a LaunchpadFormView just for sending one GET variable [20:30] i want to call https://translations.launchpad.dev/ubuntu/hoary/+translations?something [20:30] and have "something" also visible in https://translations.launchpad.dev/ubuntu/hoary/+langchart [20:31] adiroiban: I would redefine the views __init__ to call initial_values and have it inject the values into view.request.form [20:31] * sinzui wonders if that has been done before [20:33] sinzui: I will try [20:33] :) [20:37] adiroiban: there are several places where views are doing something like [20:37] self.request.form['displayname'] = my_value [20:37] to ensure sane data is in the request before a redirect or some handoff to another process. I think doing this in an __init__ is okay. [20:38] ok. I'll try and see what I can get [20:39] adiroiban: I think you want to check the form using this style: [20:39] if request.form.get('something', None) is None: [20:39] request.form['something'] = 'sane default' [20:44] i'm still learning zope and lp... so I don't know if I should pass some flag over HTTP get or encode it in the url [20:46] also I still need to read about the lifecycle/lifetime of a zope view component [20:49] adiroiban: I do not think zope will help you since we are using LaunchpadView and LaunchpadFormView [20:51] adiroiban: Those views in lib/canonical/launchpad/webapp define all the objects commonly available, the order they are gotten, and process the form data and do validation [20:52] adiroiban: The only zope knowledge I need to know is zope.formlib when I am doing something very strange in setupFields or setupWidgets. We have some many examples in views now that I do not think you need to learn that from Zope. [20:54] sinzui: thanks. [20:55] right now I'm trying to so simple things ... but then I still need to learn the LP way of doing things [20:56] so I have this page: https://translations.launchpad.dev/ubuntu/hoary/+translations?all=yes [20:56] which has an included fragment [20:57] adiroiban: the general execution path is View __init__ (we rarely mess with this, but I think you want to in this case) -> initialize (setup form stuff) -> setupFields -> setupWidgets() -> validate -> Actions -> render() [20:57] and I want to see the "all=yes" value in the fragment [21:00] adiroiban: Something like this I think: [21:00] def __init__(self, context, request): [21:00] super(MYVIEW, self).__init__(context, request) [21:00] # This view may be included as a portlet using default values. [21:00] if self.request.form.get('all', None) is None: [21:00] request.form['all'] = 'yes' [21:02] ok. but in my particular case. I have the same view for the main page and the portlet page ... [21:02] does it mean I have to slit them in different views? [21:07] adiroiban: You could subclass to have different behaviours, but I think this is a case where the view should do the right thing for default and query cases [21:08] Since setting the form in __init__ is extraordinary, we need a comment to explain that the view is used as a portlet. [21:09] sinzui: think I still need to read more as I have no idea when the __init__ or LaunchpadView.initialize() is called [21:10] init is called when the object is created...it is the constructor [21:10] and when is that . Each time I'm accessing the specific URL ? [21:11] Yes, each time. All objects are garbage collected at the end of the request. [21:12] and if I have something like this:
[21:12] it will not create a new request for that inclusion ? [21:13] That is right [21:13] then I can no use that trick [21:14] The that syntax means: Lookup and execute the adapter for translation_focus (a series) named +langchart [21:14] adiroiban: why do you need a new request? [21:15] sinzui: I don't need a new request. [21:15] i have distroseries/+translate page [21:15] that "includes" the +langchart page [21:15] now I'm calling +translate?all=yes [21:16] and I want that "all=yes" to be propagated to +langchart [21:16] ah [21:16] that is extraordinary [21:17] maybe this is not the right way to do it [21:17] So you are not seeing the form when the +langchart is called? [21:18] if it's from +translations , no [21:18] direct access is OK [21:18] direct - hacking the URL [21:19] I think you want to subclass the view then and set the all=yes as I suggested [21:19] you want to register the new view as a new name in browser/configure.zcml. [21:20] yep. I can have +translations and +translations-all [21:20] for="lp.registry.interfaces.distroseries.IDistroSeries" [21:20] class="lp.translations.browser.distroseries.AllLangsView" [21:20] name="+alllangchart" [21:20] template="../templates/distroseries-langchart.pt"/> [21:22] or +langchart-all ;) [21:24] so basically, there is no way to pass a HTTP or TAL "variable" to a fragment page? [21:24] and the only way is to create a new view ? [21:24] There is, by way of define a metal macro instead of adapting to a view [21:27] then maybe it is best to use a macro? [21:29] You would need to rewite the existing template to use the macro. I think that is more work then subclassing and registering [21:33] sinzui: thanks for the help! [21:34] so to finalize. there is no easy way for something like this:
[21:34] easy, trivial [21:36] I do not think so [21:40] the @@+fragment way of include is specific to Zope , or is a LP TALES extension? [21:40] It is TALES, which is neither zope or lp [21:40] :) [21:41] Here is a quick reference I often use. http://www.owlfish.com/software/simpleTAL/tal-guide.html [21:42] TALES and METAL are associated with zope, but the engine is not specific to zope any more [21:47] well. I will go with the sollution where multiple views are created and I will see what is the feedback from the reviewer :)