Thursday, June 20, 2019

Re: Component design question

Damnit, my port was wrong above, here goes, with list for content and
dict for attributes as arguments instead of using *args, **kwargs:


if not request.user.is_authenticated:
content.append(
Li(
[A([_('Log in')], dict(href=reverse('crudlfap:login')))],
dict(cls='no-padding'),
)
)
else:
content.append(Li([A(
[_('Log out')],
{
'class': 'waves-effect',
'data-noprefetch': 'true',
'href': reverse('crudlfap:logout'),
}
)], {'class': 'no-padding'}))

The good side is that this mistake does make it look like it's more
error-prone than relying on some magic with *args, **kwargs. By magic
i mean: constructor take all *args, each arg that is text or a
component goes in self.content, if an arg is an Event then it goes in
self.events, although kwargs['events'] might also be set to a list ...

Would you favor readability in user code over readability in
constructor of core class Component ?

Thanks in advance

--


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAC6Op1-Hyt_nP2-kNxGyLK7T%2BSa%2BtjHqctWgKimwvw6Hbu1_%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment