[tg-trunk] Re: Proposal: Events
Em Domingo 23 Abril 2006 09:49, Jeff Watkins escreveu: Well, my turn to confess: I haven't been following FirstClass at all. Me neither, but I believe this is a big change to go into 1.0 and this is why I asked. If it is not all that big, then I retreat my questioning :-) I'd envisioned the event mechanism to be a generic system for components to use to alert application code to certain actions. I like the idea that my application code could register to be alerted just before (or after) an HTTP request completes (just an example) or before a Visit is created. Sure! I also see some useful things with it. I was not questioning that just how and when would it be made available. :-) I still don't grasp WSGI and I should allocate some time to learn it as I envision that it would make a lot of things easier to me from what I've been reading, but... :-( -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Proposal: Events
Yep. And you'd never understand *why* your login was rejected.On 23 Apr, 2006, at 1:57 pm, Simon Belak wrote:Were Identity based on generic functions (as was proposed using a very similar use case), one would get a very capable event system for free. ;) --Jeff Watkinshttp://newburyportion.com/"Just because you have the right to do something, doesn't mean it's the right thing to do."-- Fred Friendly, former president of CBS News --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Please flame me: I would like to move validator to InputWidget...
Ok, the subject is ironically talking about a flame since there is a bad hair ATM in the main mailing list but let's talk about things that matter. :D Fact: while reading Tim widgets introduction I noticed this thing (that I was sure to find at some point somewhere): You'll note that the template references value, which is the standard TurboGears name used to apply data to the widget. and in the template: tr py:for=player in value Now if I was the one to write such a widget I would never have used value but: params = [players] and: tr py:for=player in players So that's what I want to do: move the validator attribute to InputWidget along with: - default/value - adjust_value - value_for - convert - is_named - probably name? I never give a name to a non-form generic widget Reasons (very good IMHO): The base Widget class should be the most basic one and should present a general concept of component without making assumptions regarding the params that will be used (value is assumed in this case). The validator concept is pretty specific to Form validation and FormEncode, the value concept is also pretty specific to this thing I (for myself) will never use value in a non form widget and would like to encourage other people to not use it but use self explanatory names. What about from_python? Yes, I know a validator can be useful when you need to convert from_python to the web and don't need to_python, but if you need such a thing for a *non-form* widget *then* you will most probably need a custom FE validator and at this point I will not use a custom validator to just provide a from_python method but I will simply implement this logic inside update_data (that's what I'm doing with my generics widgets), otherwise you should explain to someone not only that value is *always* special treated but that he needs to implement a custom class like this one: class MyValidator(validators.FancyValidator): _from_python(self, value): ... and all the logic behind this class and FE concepts like FancyValidator instead of just putting some lines in update_data, why on hearth? and two ways of doing it? Other than that FormEncode as the name says is pretty much form oriented. Benefits: We have a nice, clean, slim and easy to use, explain and understand Widget base class that is *only* focused on the creation of reusable-components. TG show how you can use such a class to provide a very powerful form managing system, if you really want the validator you can use InputWidget directly. The base class becomes something like: class Widget(object): __metaclass__ = MetaWidget template = None params = [] css = [] javascript = [] def __init__(self, template=None, **params) def update_data(self, params) def display(self, **params) def render(self, format=html, **params) def retrieve_javascript() def retrieve_css() Just lovely IMHO (probably more with __javascript__ and __css__ :P:P). Ok, I know we shouldn't continue to touch things but I can't think of any backward incompatibility (please point them out if you can see them) and these functionalities are just shifted to InputWidget, that's where they really belong IMHO. Enough craziness for today? good night guys. Ciao Michele --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Please flame me: I would like to move validator to InputWidget...
Michele Cella wrote: class Widget(object): __metaclass__ = MetaWidget template = None params = [] css = [] javascript = [] def __init__(self, template=None, **params) def update_data(self, params) def display(self, **params) def render(self, format=html, **params) def retrieve_javascript() def retrieve_css() Just lovely IMHO (probably more with __javascript__ and __css__ :P:P). mmm while we are at it and since you will flame anyway, to be even more lovely I will also add that the ideal thing will be renaming update_data to update_params to enforce the strong relationship between the two things. Everything that's inside params ends up in the dict passed to update_data, so this should really be update_params, well Kevin named this method update_data before we introduced something like template_vars/params... Ciao Michele --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Please flame me: I would like to move validator to InputWidget...
Em Domingo 23 Abril 2006 21:22, Michele Cella escreveu: (...) The base Widget class should be the most basic one and should present a general concept of component without making assumptions regarding the params that will be used (value is assumed in this case). I don't believe we should try solving or enforcing good practices by making it harder for them to shoot themselves in their feet. We shouldn't change things just because of that. We have a nice, clean, slim and easy to use, explain and understand Widget base class that is *only* focused on the creation of reusable-components. This looks good to have... But it is achievable as of today. I've done that with Select-Shuttle and MochiInterpreter, both on CheeseShop... Ok, I know we shouldn't continue to touch things but I can't think of any backward incompatibility (please point them out if you can see them) and these functionalities are just shifted to InputWidget, that's where they really belong IMHO. Enough craziness for today? good night guys. If no test fails and nobody sees any trouble with that I have no objection. Besides, better doing that before 0.9a5 than later. But I really would like that this became more stable. If it is to make it easier, go for it. -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Please flame me: I would like to move validator to InputWidget...
Em Domingo 23 Abril 2006 21:41, Michele Cella escreveu: mmm while we are at it and since you will flame anyway, to be even more lovely I will also add that the ideal thing will be renaming update_data to update_params to enforce the strong relationship between the two things. I have the same opinion. -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Please flame me: I would like to move validator to InputWidget...
Em Domingo 23 Abril 2006 22:01, Michele Cella escreveu: - why should I name my grid? (mmm, to have more then one in the same page and distinguish them for javascript purpose, +1 for keeping name inside widget) ;-) We should always plan for more than one per page or per form. :-) It is safer and allows some unusual design. -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] Re: Please flame me: I would like to move validator to InputWidget...
Jorge Godoy wrote: Em Domingo 23 Abril 2006 21:41, Michele Cella escreveu: mmm while we are at it and since you will flame anyway, to be even more lovely I will also add that the ideal thing will be renaming update_data to update_params to enforce the strong relationship between the two things. I have the same opinion. Mmm, but in a Compound update_data also receives member_widgets so it probably makes more a more generic name... But well, haven't I said that I should sleep? :D Good night, for real this time. Ciao Michele --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---
[tg-trunk] CompoundWidgets versus validators.Schema
Well... What should I validate in a compound widget such as the AutoCompleteField? The syntax of a validator looks like: name = validator Where name is the parameter that is being returned from HTML. The problem is that the name that is generated there is not tied to the name I provided. Here's the HTML generated for the AutoCompleteField that I mentioned in #777: === DIV SCRIPT TYPE=text/JavaScript LANGUAGE=JavaScript AutoCompleteManagerform_endereco = new AutoCompleteManager('form_endereco', 'form_endereco_endereco_text', 'form_endereco_hidden', '/fornecedores/search_endereco', 'endereco', 'enderecos',false); addLoadEvent(AutoCompleteManagerform_endereco.initialize); /SCRIPT INPUT NAME=endereco.endereco_text CLASS=textfield TYPE=text ID=form_endereco_endereco_text VALUE=R. Poeta Francisco Ferreira Leite, 40 - 6 SIZE=51 IMG SRC2=/tg_widgets/turbogears.widgets/spinner.gif SRC=/tg_widgets/turbogears.widgets/spinnerstopped.png NAME=autoCompleteSpinnerendereco ID=autoCompleteSpinnerform_endereco DIV CLASS=autoTextResults ID=autoCompleteResultsform_endereco NAME=autoCompleteResultsendereco /DIV INPUT CLASS=hiddenfield TYPE=hidden ID=form_endereco_hidden NAME=endereco.hidden /DIV === I want to validate, e.g., the field that has the name endereco.endereco_text -- the name I gave to the AutoCompleteField was endereco and the name for the text_field was endereco_text. The code is: === endereco = widgets.AutoCompleteField( search_controller=/fornecedores/search_endereco, search_param=endereco, result_name=enderecos, text_field = widgets.TextField(name = 'endereco_text', attrs = {'size':51}, label = _(u'Endereço'),)) === The derived name is not obvious and one will always have to look at the output to know the name of the field he'll be validating since it isn't anything he typed in. I'd expect to have to validate endereco_text or even just endereco since I haven't specified a hidden field but have specified a text_field. But since it is made of two separate widgets, I'd be fine validating the inner field. What I want here? To write something like: endereco.endereco_text = validators.UnicodeString() But if I do that, then I'll receive an error message stating that there's no 'endereco' object or not 'endereco_text' attribute for the inexistent object. Won't I? testing Yes, I get an error: === NameError: name 'endereco' is not defined === So, if the name there has a . in it, I can't create a Schema with that name and this name is what is returned as the key in the key=value pair that we receive from the web before any processing. What should I write as the validator name to validate this field? And why are validators for the form ignored when I declare them on the widgets.WidgetsList and concatenate several of these into a form? -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Trunk group. To post to this group, send email to turbogears-trunk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-trunk -~--~~~~--~~--~--~---