thanks for reply. Yes, I've showed 3 ways of checking if var was previously defined, but the question was about preferred way of doing that in Web2Py, also I want to add 'not empty' to this check.
> If you are the developer you should know what variables you are going to be using in the view? It may happen that views are written by other people, etc, isn't it better to introduce as much independence as possible? Here is my case, but I guess there may be other similar. I keep content for my static pages in db. It is broken in parts like footer_block, header_block, content_block, etc. And I use blocks in views, so I can fill parts of view with content from db, or leave them with default content from extended view (i.e. my version of layout.html) with {{super}}. Also, some part of page can empty in db. So, I thought that it would be a good idea to return only non-empty parts to the view, and in case when some part is empty in db, it will not be passed to the view, and content from extended layout will be used. Does it make sense? On Sunday, July 7, 2013 11:52:54 PM UTC+3, villas wrote: > > It seems that you already know how to check whether variables exist, so > you have already answered the question. > > However, I think the entire premise of the question seems strange. If > you are the developer you should know what variables you are going to be > using in the view? So, just make sure they always exist so you don't have > to mess up your view with all those tests. > > Maybe if you doing something unusal it is better to state the use case? > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.