[web2py] Re: Should IS_TIME accept format?
Undoubtedly it would be more coherent to have the possibility to set the time format as in IS_DATE and IS_DATETIME. On Friday, March 12, 2010 4:07:46 PM UTC+1, mdipierro wrote: > > good point. I will take the patch. > > On Mar 12, 9:01 am, DenesL wrote: > > To drop the seconds value as in the example format '%H:%M' above. > > > > On Mar 12, 8:07 am, mdipierro wrote: > > > > > The 'time' fields have a JS time picker. If you choose to do > > > > > db.table.field.requires.formatter=lambda v: v.strftime('%H-%M') > > > instead of > > > db.table.field.requires.formatter=lambda v: v.strftime('%H:%M') > > > > > the time picker would not recognize it as valid time. Why would > > > anybody change the time format? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] How to use define_table format parameter beyond referenced records in select drop-downs?
given a simple table db.define_table('person', Field('first_name'), Field('second_name'), format='%(first_name) %(second_name)' ) and a row object row = db.person(1) how can I print the row object formatted according to the format parameter defined in the model? I mean something like the default behaviour of the SQLForm select widget for referenced table. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: bootstrap 3 - if you care help test trunk now
Hi Massimo, I was reading this page in the manual: http://web2py.com/books/default/chapter/29/12/components-and-plugins#Layout-plugins *What do you think about putting the (presently) default bootstrap 2 layout in a plugin?* In this way you will ship directly web2py with these: static/plugin_layout_*default_bootstrap2*/ views/plugin_layout_*default_bootstrap2*/layout.html and having the bootstrap 2 layout "encapsulated" like this it will be easier for us to test new bootstrap 3 as a layout plugin in existing applications (instead of having to create new apps from trunk), and also will be easier later to ship web2py with both bootstrap 2 and bootstrap 3 implementations so that people can choose between them just by modifying *views/layout.html* as explained in the manual: {{extend 'plugin_layout_name/layout.html'}} {{include}} PS maybe you already did this, I didn't notice this post before so I didn't have time to download and test the master.zip yet. On Saturday, August 9, 2014 9:13:38 AM UTC+2, Massimo Di Pierro wrote: > > Bootstrap 3 is in trunk now. Please help us test it. > Also help us test that existing apps are not broken. > > Massimo > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: How do I apply placeholder text to web2py forms?
Method 1 can be easily generalized in a function that set the placeholder for all sqlform fields and strip away all labels and comments: def autoset_form_placeholders(form, form_labels=False, form_comments=False): for f in form.fields: if f == 'id': pass else: form.custom.widget[f].update(_placeholder=f) if not form_labels: form.elements('.w2p_fl', replace=None) if not form_comments: form.elements('.w2p_fc', replace=None) On Thursday, June 23, 2011 6:04:55 PM UTC+2, Anthony wrote: > > A couple other methods: > > 1. In the controller or view: > > form.custom.widget.first_name.update(_placeholder="first name") > > or > > 2. Customize the db.yourtable.first_name widget: > > db.define_table('yourtable', Field('first_name', > widget=lambda field,value: SQLFORM.widgets.string.widget(field, value, > _placeholder='first name')), > [rest of table definition]) > > or specify it after table definition via > db.yourtable.first_name.widget=lambda... > > Method #2 will apply the change to all forms that include that field. > > There should probably be an easier/more straightforward way to do this, > though. All the widgets take keyword arguments, but it doesn't look like > there's an easy way to pass them in when the widgets are associated with db > table fields. > > Anthony > > > On Thursday, June 23, 2011 10:55:19 AM UTC-4, Massimo Di Pierro wrote: > >> form.element(_id='...')['_placeholder']='...' >> >> On Jun 23, 9:24 am, Carl wrote: >> > I'm using custom forms in my views using this format: >> > {{=form.custom.widget.first_name}} >> > >> > I'd like to use HTML's placeholder attribute to input tags: e.g., >> > >> > >> > Today: what are the ways to enable this? Obviously happy to drop the >> > {{=form.custom.widget.first_name}} format and use something else. >> > >> > Tomorrow: might it be a good idea to add placeholder attribute to >> > db.Field() in a similar fashion to how 'label' has already been added? > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: web2py shell vs terminal shell
no I didn't. Anyway, now I just tried without opening the two prompt, just opening the GUI from the .bat file, and I didn't truncate the table, I just did an insert. Then I tried to input some other commands and it keeps repeating the insert. So it seems it's not the truncate. I tried also the db.commit() but it didn't change the behaviour, the online shell keeps repeating the inserts. What is strange is that the other day it also repeated the truncate commands, but now I am unable to reproduce that, it only repeats the inserts. On Mon, Aug 18, 2014 at 6:22 AM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > After truncate the table did you db.commit()? > > > On Sunday, 17 August 2014 23:17:29 UTC-5, Giacomo Dorigo wrote: >> >> I don't know, >> for some reason it does not leave me submit the ticket: >> >> Windows 8 >> web2py : >> 2.9.5-stable+timestamp.2014.03.16.02.35.39 >> (Running on Rocket 1.2.6, Python 2.7.7) >> >> What steps will reproduce the problem? >> 1. run web2py from source code from a .bat file python >> path_to_web2py/web2py.py >> 2. at same time run an other instance of web2py from terminal so: >> path_to_web2py/web2py.py -S myapp -M >> 3. start to interact with the db api from the online shell (not from the >> command line) >> 4. insert some records >> 5. truncate the table >> 6. insert new records >> >> =>> check the table, the old inserts had been repeated again >> >> What is the expected output? >> only the new inserts should have been inserted >> >> >> On Sun, Aug 17, 2014 at 6:18 AM, Massimo Di Pierro < >> massimo.dipie...@gmail.com> wrote: >> >>> https://code.google.com/p/web2py/issues/entry >>> >>> >>> On Saturday, 16 August 2014 23:08:36 UTC-5, Giacomo Dorigo wrote: >>>> >>>> OK, how do I open a ticket? >>>> >>>> >>>> On Wed, Aug 13, 2014 at 8:04 PM, Massimo Di Pierro < >>>> massimo.dipie...@gmail.com> wrote: >>>> >>>>> Please open a ticket about this. This is a major issue. Perhaps we >>>>> should remove the web based shell. >>>>> >>>>> >>>>> On Wednesday, 13 August 2014 02:41:17 UTC-5, Giacomo Dorigo wrote: >>>>>> >>>>>> Today I discovered an other problem with the admin shell. >>>>>> If I execute command 1 >>>>>> and then command 2, at this point it will re-execute command 1 too. >>>>>> If then I execute command 3, it will execute again also 1 and 2. >>>>>> >>>>>> This is while running web2py from source code on Windows with simple >>>>>> python web2py.py >>>>>> >>>>>> >>>>>> >>>>>> On Saturday, April 6, 2013 6:09:40 AM UTC+2, Massimo Di Pierro wrote: >>>>>>> >>>>>>> The admin shell has problems maintaining state. I do not consider it >>>>>>> reliable. The terminal shell is rock solid. It is a normal pyhton shell. >>>>>>> >>>>>>> On Friday, 5 April 2013 16:48:50 UTC-5, Michael Herman wrote: >>>>>>>> >>>>>>>> yes. so when working with DAL directly from the shell it's better >>>>>>>> to >>>>>>>> work from the web2py shell in the terminal rather than the admin >>>>>>>> app >>>>>>>> shell? any idea why? >>>>>>>> >>>>>>>> On Fri, Apr 5, 2013 at 2:43 PM, Anthony wrote: >>>>>>>> > >>>>>>>> > By "built-in" shell, do you mean the one in the admin app? I >>>>>>>> think there are sometimes problems with that (particularly with >>>>>>>> database >>>>>>>> operations), so I tend to use the web2py shell in the terminal, which >>>>>>>> you >>>>>>>> can start as follows from the web2py directory: >>>>>>>> > >>>>>>>> > python web2py.py -S yourapp/[optional controller] -M >>>>>>>> > >>>>>>>> > But you may fine the admin shell works just fine for you, in >>>>>>>> which case, use it. >>>>>>>> > >>>>>>>> > Anthony >>>>>>>> > >>>>>>>> > &
[web2py] Re: Using cache for improving pagination recipe in the manual?
In the end I solved with two simple classes, without using cache, but with two queries, one counting total items and one limited by limitby. Also I have looked in slices and I found some pagination plugins. Anyway here the basic code: class PageThread(object): def __init__(self, query, items_per_page=10): self.query = query self.items_count = db(self.query).count() self.items_per_page = items_per_page self.__set_number_of_pages() def __set_number_of_pages(self): self.number_of_pages = self.items_count/self.items_per_page + 1 if self.items_count % self.items_per_page else self.items_count/self.items_per_page def serve_page(self, page_id): page_items = db(self.query).select(limitby=((page_id-1)*self.items_per_page, page_id*self.items_per_page)) p = Page(page_id, page_items) p.previous_pages = [n for n in range(1, page_id)] p.next_pages = [n for n in range(page_id+1, self.number_of_pages+1)] return p class Page(object): def __init__(self, id, items): # id is the unique number of the page in the PageThread self.id = id self.items = items def __str__(self): return 'Page n.{}, {} items: {}'.format(self.id, len(self.items), self.items) def get_page_navigation_div(self, **request_vars): request_vars.update({'items_per_page': len(self.items)}) previous_pages_subdiv = DIV(_class='previous-pages-subdiv') next_pages_subdiv = DIV(_class='next-pages-subdiv') if self.previous_pages: request_vars.update({'page': self.id-1}) previous_pages_subdiv.append( A('<<< previous', _class='nav-previous-link', _href=URL(vars=request_vars)) ) for n in self.previous_pages: request_vars.update({'page': n}) previous_pages_subdiv.append( A(' %s' % n, _class='nav-previous-pages', _href=URL(vars=request_vars)) ) for n in self.next_pages: request_vars.update({'page': n}) next_pages_subdiv.append( A(' %s' % n, _class='nav-next-pages', _href=URL(vars=request_vars)) ) if self.next_pages: request_vars.update({'page': self.id+1}) next_pages_subdiv.append( A(' next >>>', _class='nav-next-link', _href=URL(vars=request_vars)) ) return DIV(previous_pages_subdiv, next_pages_subdiv, _class='page-navigation-div') def get_style(self): style = STYLE("""\ .page-navigation-div { width: 1170px; } .page-navigation-div div { display: inline; } .page-navigation-div .next-pages-subdiv{ float: right; } """) return style -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: Using cache for improving pagination recipe in the manual?
Well, the 10 rows for 30 p was just an example for understanding :) The idea of the was in order to do only 1 query but definitely you are right, it wasn't worth of! On 18 Aug 2014 12:23, "Niphlod" wrote: > if you're presenting 10 rows at a time and expecting the user to navigate > 30 pages, "you're doing it wrong", from the UX side of things. > On the other side, there's no reason to cache "in advance" something the > user will never ask. Let the cache be the cache. If you need to "warm it > up", just do > > cached_it = False #you logic to see if the cache needs to be updated > if not cached_it: > for i in range(number_of_pages): > rtn = db(query).select(limitby=(number_of_pages*no_of_records, > (number_of_pages+1)*no_of_records)) > cached_it = True > > but mind that is quite silly. > > On Saturday, August 16, 2014 10:26:45 AM UTC+2, Giacomo Dorigo wrote: >> >> I have read the manual recipe on pagination: >> http://web2py.com/books/default/chapter/29/14/other-recipes#Pagination >> >> That works fine if we just want to have a page aware if it has a previous >> or next one, but what if we want also to get the list of all next pages? >> i.e. by putting a link for each next page, near the next "button"? >> >> Let's say I have 300 records in a table, I want to serve 10 per time. If >> I am serving page 1, there are other 29 pages more, so I want to be able to >> put links at least to page 2, 3, 4, 5, 6 so to make navigation easier. >> >> The recipe in the manual is quite good, because it allows to get only the >> 10 elements I need to serve in the current page, but my page do not know >> how many pages there are in total. >> >> I was thinking to solve this creating a PageThread class taking care of >> storing the information about the whole. My idea was to let this class >> making the query for all items in the table and then creating the single >> pages to serve. >> But the problem here is that when the controller will instantiate this >> class it will reset it all times, so it will make the query to the whole >> table every time, so it's wasted. >> Probably this can be solved using the web2py built-in count() or is there >> a possibility to use cache? >> Does anybody already solved this problem somewhere? >> >> This is a sample of the code of the two classes I thought about: >> >> class PageThread(object): >> def __init__(self, items, items_per_page=10): >> self.items = items >> self.items_count = len(self.items) >> self.items_per_page = items_per_page >> self.__set_number_of_pages() >> self.__load_pages() >> >> def __set_number_of_pages(self): >> self.number_of_pages = self.items_count/self.items_per_page + 1 >> if self.items_count % self.items_per_page else self.items_count/self. >> items_per_page >> >> def __load_pages(self): >> self.pages = [Page(p_id, self.items[(p_id-1)*self.items_per_page: >> p_id*self.items_per_page]) for p_id in range(1, self.number_of_pages+1)] >> >> >> class Page(object): >> def __init__(self, id, items): >> # id is the unique number of the page in the PageThread >> self.id = id >> self.items = items >> >> def __str__(self): >> return 'Page n.{}, {} items: {}'.format(self.id, len(self.items), >> self.items) >> >> While this was the original Page that just knows if it has previous or >> next: >> >> class Page(object): >> def __init__(self, page, items_per_page=10): >> self.id = int(page) >> self.items_per_page = items_per_page >> # range gives you an item more in order to check if there is a >> next page >> self.range = ((self.id-1)*self.items_per_page, self.id*self. >> items_per_page+1) >> >> >> def load_items(self, rows): >> # where rows are those returned from a select query to the db >> if len(rows) > self.items_per_page : >> self.has_next = True >> self.items = rows[:-1] >> else: >> self.has_next = False >> self.items = rows >> >> >> def get_page_navigation_div(self, **request_vars): >> contents = [] >> request_vars.update({'items_per_page': self.n_items}) >> if self.has_previous: >> request_vars.update({'page': self.id-1}) >>
Re: [web2py] Re: web2py shell vs terminal shell
I don't know, for some reason it does not leave me submit the ticket: Windows 8 web2py : 2.9.5-stable+timestamp.2014.03.16.02.35.39 (Running on Rocket 1.2.6, Python 2.7.7) What steps will reproduce the problem? 1. run web2py from source code from a .bat file python path_to_web2py/web2py.py 2. at same time run an other instance of web2py from terminal so: path_to_web2py/web2py.py -S myapp -M 3. start to interact with the db api from the online shell (not from the command line) 4. insert some records 5. truncate the table 6. insert new records =>> check the table, the old inserts had been repeated again What is the expected output? only the new inserts should have been inserted On Sun, Aug 17, 2014 at 6:18 AM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > https://code.google.com/p/web2py/issues/entry > > > On Saturday, 16 August 2014 23:08:36 UTC-5, Giacomo Dorigo wrote: >> >> OK, how do I open a ticket? >> >> >> On Wed, Aug 13, 2014 at 8:04 PM, Massimo Di Pierro < >> massimo.dipie...@gmail.com> wrote: >> >>> Please open a ticket about this. This is a major issue. Perhaps we >>> should remove the web based shell. >>> >>> >>> On Wednesday, 13 August 2014 02:41:17 UTC-5, Giacomo Dorigo wrote: >>>> >>>> Today I discovered an other problem with the admin shell. >>>> If I execute command 1 >>>> and then command 2, at this point it will re-execute command 1 too. >>>> If then I execute command 3, it will execute again also 1 and 2. >>>> >>>> This is while running web2py from source code on Windows with simple >>>> python web2py.py >>>> >>>> >>>> >>>> On Saturday, April 6, 2013 6:09:40 AM UTC+2, Massimo Di Pierro wrote: >>>>> >>>>> The admin shell has problems maintaining state. I do not consider it >>>>> reliable. The terminal shell is rock solid. It is a normal pyhton shell. >>>>> >>>>> On Friday, 5 April 2013 16:48:50 UTC-5, Michael Herman wrote: >>>>>> >>>>>> yes. so when working with DAL directly from the shell it's better to >>>>>> work from the web2py shell in the terminal rather than the admin app >>>>>> shell? any idea why? >>>>>> >>>>>> On Fri, Apr 5, 2013 at 2:43 PM, Anthony wrote: >>>>>> > >>>>>> > By "built-in" shell, do you mean the one in the admin app? I think >>>>>> there are sometimes problems with that (particularly with database >>>>>> operations), so I tend to use the web2py shell in the terminal, which you >>>>>> can start as follows from the web2py directory: >>>>>> > >>>>>> > python web2py.py -S yourapp/[optional controller] -M >>>>>> > >>>>>> > But you may fine the admin shell works just fine for you, in which >>>>>> case, use it. >>>>>> > >>>>>> > Anthony >>>>>> > >>>>>> > >>>>>> > On Friday, April 5, 2013 4:57:49 PM UTC-4, Michael Herman wrote: >>>>>> >> >>>>>> >> i remember reading somewhere that it's better to use the built-in >>>>>> shell in web2py, but i can't find the article/post. anyone know (1) if it >>>>>> is "better", and, (2) if so, why? >>>>>> > >>>>>> > -- >>>>>> > >>>>>> > --- >>>>>> > You received this message because you are subscribed to a topic in >>>>>> the Google Groups "web2py-users" group. >>>>>> > To unsubscribe from this topic, visit https://groups.google.com/d/ >>>>>> topic/web2py/XWMt1Pb_2wk/unsubscribe?hl=en. >>>>>> > To unsubscribe from this group and all its topics, send an email to >>>>>> web2py+un...@googlegroups.com. >>>>>> > For more options, visit https://groups.google.com/groups/opt_out. >>>>>> > >>>>>> > >>>>>> >>>>>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to a topic in the >>>
Re: [web2py] Re: web2py shell vs terminal shell
OK, how do I open a ticket? On Wed, Aug 13, 2014 at 8:04 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > Please open a ticket about this. This is a major issue. Perhaps we should > remove the web based shell. > > > On Wednesday, 13 August 2014 02:41:17 UTC-5, Giacomo Dorigo wrote: >> >> Today I discovered an other problem with the admin shell. >> If I execute command 1 >> and then command 2, at this point it will re-execute command 1 too. >> If then I execute command 3, it will execute again also 1 and 2. >> >> This is while running web2py from source code on Windows with simple >> python web2py.py >> >> >> >> On Saturday, April 6, 2013 6:09:40 AM UTC+2, Massimo Di Pierro wrote: >>> >>> The admin shell has problems maintaining state. I do not consider it >>> reliable. The terminal shell is rock solid. It is a normal pyhton shell. >>> >>> On Friday, 5 April 2013 16:48:50 UTC-5, Michael Herman wrote: >>>> >>>> yes. so when working with DAL directly from the shell it's better to >>>> work from the web2py shell in the terminal rather than the admin app >>>> shell? any idea why? >>>> >>>> On Fri, Apr 5, 2013 at 2:43 PM, Anthony wrote: >>>> > >>>> > By "built-in" shell, do you mean the one in the admin app? I think >>>> there are sometimes problems with that (particularly with database >>>> operations), so I tend to use the web2py shell in the terminal, which you >>>> can start as follows from the web2py directory: >>>> > >>>> > python web2py.py -S yourapp/[optional controller] -M >>>> > >>>> > But you may fine the admin shell works just fine for you, in which >>>> case, use it. >>>> > >>>> > Anthony >>>> > >>>> > >>>> > On Friday, April 5, 2013 4:57:49 PM UTC-4, Michael Herman wrote: >>>> >> >>>> >> i remember reading somewhere that it's better to use the built-in >>>> shell in web2py, but i can't find the article/post. anyone know (1) if it >>>> is "better", and, (2) if so, why? >>>> > >>>> > -- >>>> > >>>> > --- >>>> > You received this message because you are subscribed to a topic in >>>> the Google Groups "web2py-users" group. >>>> > To unsubscribe from this topic, visit https://groups.google.com/d/ >>>> topic/web2py/XWMt1Pb_2wk/unsubscribe?hl=en. >>>> > To unsubscribe from this group and all its topics, send an email to >>>> web2py+un...@googlegroups.com. >>>> > For more options, visit https://groups.google.com/groups/opt_out. >>>> > >>>> > >>>> >>>> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/XWMt1Pb_2wk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Using cache for improving pagination recipe in the manual?
I have read the manual recipe on pagination: http://web2py.com/books/default/chapter/29/14/other-recipes#Pagination That works fine if we just want to have a page aware if it has a previous or next one, but what if we want also to get the list of all next pages? i.e. by putting a link for each next page, near the next "button"? Let's say I have 300 records in a table, I want to serve 10 per time. If I am serving page 1, there are other 29 pages more, so I want to be able to put links at least to page 2, 3, 4, 5, 6 so to make navigation easier. The recipe in the manual is quite good, because it allows to get only the 10 elements I need to serve in the current page, but my page do not know how many pages there are in total. I was thinking to solve this creating a PageThread class taking care of storing the information about the whole. My idea was to let this class making the query for all items in the table and then creating the single pages to serve. But the problem here is that when the controller will instantiate this class it will reset it all times, so it will make the query to the whole table every time, so it's wasted. Probably this can be solved using the web2py built-in count() or is there a possibility to use cache? Does anybody already solved this problem somewhere? This is a sample of the code of the two classes I thought about: class PageThread(object): def __init__(self, items, items_per_page=10): self.items = items self.items_count = len(self.items) self.items_per_page = items_per_page self.__set_number_of_pages() self.__load_pages() def __set_number_of_pages(self): self.number_of_pages = self.items_count/self.items_per_page + 1 if self.items_count % self.items_per_page else self.items_count/self. items_per_page def __load_pages(self): self.pages = [Page(p_id, self.items[(p_id-1)*self.items_per_page: p_id*self.items_per_page]) for p_id in range(1, self.number_of_pages+1)] class Page(object): def __init__(self, id, items): # id is the unique number of the page in the PageThread self.id = id self.items = items def __str__(self): return 'Page n.{}, {} items: {}'.format(self.id, len(self.items), self.items) While this was the original Page that just knows if it has previous or next: class Page(object): def __init__(self, page, items_per_page=10): self.id = int(page) self.items_per_page = items_per_page # range gives you an item more in order to check if there is a next page self.range = ((self.id-1)*self.items_per_page, self.id*self. items_per_page+1) def load_items(self, rows): # where rows are those returned from a select query to the db if len(rows) > self.items_per_page : self.has_next = True self.items = rows[:-1] else: self.has_next = False self.items = rows def get_page_navigation_div(self, **request_vars): contents = [] request_vars.update({'items_per_page': self.n_items}) if self.has_previous: request_vars.update({'page': self.id-1}) contents.append( A('<<< previous', _class='nav-previous', _href= URL(vars=request_vars)) ) for n in range(1, self.id): request_vars.update({'page': n}) contents.append( A(' %s' % n, _class='nav-page', _href=URL(vars= request_vars)) ) if self.has_next: request_vars.update({'page': self.id+1}) contents.append( A('next >>>', _class='nav-next', _href=URL(vars =request_vars)) ) return DIV(*contents, _id='page_navigation') In the controller you use like this: page = Page(request.vars.page, 10) page.load_items(db(your_query).select(limitby=page.range)) #do stuff return dict(page=page) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: web2py shell vs terminal shell
Today I discovered an other problem with the admin shell. If I execute command 1 and then command 2, at this point it will re-execute command 1 too. If then I execute command 3, it will execute again also 1 and 2. This is while running web2py from source code on Windows with simple python web2py.py On Saturday, April 6, 2013 6:09:40 AM UTC+2, Massimo Di Pierro wrote: > > The admin shell has problems maintaining state. I do not consider it > reliable. The terminal shell is rock solid. It is a normal pyhton shell. > > On Friday, 5 April 2013 16:48:50 UTC-5, Michael Herman wrote: >> >> yes. so when working with DAL directly from the shell it's better to >> work from the web2py shell in the terminal rather than the admin app >> shell? any idea why? >> >> On Fri, Apr 5, 2013 at 2:43 PM, Anthony wrote: >> > >> > By "built-in" shell, do you mean the one in the admin app? I think >> there are sometimes problems with that (particularly with database >> operations), so I tend to use the web2py shell in the terminal, which you >> can start as follows from the web2py directory: >> > >> > python web2py.py -S yourapp/[optional controller] -M >> > >> > But you may fine the admin shell works just fine for you, in which >> case, use it. >> > >> > Anthony >> > >> > >> > On Friday, April 5, 2013 4:57:49 PM UTC-4, Michael Herman wrote: >> >> >> >> i remember reading somewhere that it's better to use the built-in >> shell in web2py, but i can't find the article/post. anyone know (1) if it >> is "better", and, (2) if so, why? >> > >> > -- >> > >> > --- >> > You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> > To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/XWMt1Pb_2wk/unsubscribe?hl=en. >> > To unsubscribe from this group and all its topics, send an email to >> web2py+un...@googlegroups.com. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Integration with Google Cloud Storage
I have some difficulties in integrating web2py, Google App Engine and Google Cloud Storage. Integration with Amazon S3 is much much easier, in particular if using PyFilesystem http://docs.pyfilesystem.org/en/latest/introduction.html Is there any similar library for GCS? I tried to search for something and I found this> https://bitbucket.org/nikratio/s3ql/overview Are you aware of anything else? Thanks, G. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Managing 600MB size files on Google Cloud with web2py
Hello everybody, I am writing an app for storing and delivering files more or less from 3 up to 600Mb size. I would like to rely on Google App Engine for running my web2py instance. What I am wondering if it's better to store the data directly in the Google not relational datastore (Google Cloud Datastore), or to upload them to the Google relational MySQL version (Google Cloud SQL), or in the end to implement the upload/download to the Google Cloud Storage treating it as alternative uploadfs. Does anybody have any suggestion or experience on this topic? Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: Hiding submit button on Crud forms
Thank you Massimo, I was sensing something like that :) On Sun, Jul 20, 2014 at 5:41 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > Please do not use crud. That code has not been touched in 3 years. There > is really nothing in crud that cannot be done better with > SQLFORM(..).process() > > On Saturday, 19 July 2014 03:30:31 UTC-5, Giacomo Dorigo wrote: >> >> I also did't find how to do that with CRUD, neither understood if there's >> a way to customize the submit button label. >> >> On Friday, July 1, 2011 3:16:04 AM UTC+2, mr.freeze wrote: >>> >>> Hello! I've been away for a while but am diving back into web2py for a >>> new project. I want to host my Crud forms in jqueryui dialogs so I >>> need to hide the submit button. I know I can do it using >>> form.element("input",_type="submit")["_style"] = "display:none;" >>> trickery but I want to avoid extra processing like this. With SQLFORM >>> you can pass buttons=[] but not so much with Crud. Am I just missing >>> it? >> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/vulVLm48mPg/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Hiding submit button on Crud forms
I also did't find how to do that with CRUD, neither understood if there's a way to customize the submit button label. On Friday, July 1, 2011 3:16:04 AM UTC+2, mr.freeze wrote: > > Hello! I've been away for a while but am diving back into web2py for a > new project. I want to host my Crud forms in jqueryui dialogs so I > need to hide the submit button. I know I can do it using > form.element("input",_type="submit")["_style"] = "display:none;" > trickery but I want to avoid extra processing like this. With SQLFORM > you can pass buttons=[] but not so much with Crud. Am I just missing > it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] problems loading TODO element in editor
Hello to everybody, I am running web2py on pythonanywhere platform and the TODO element at the bottom left corner of the code editor keeps loading forever. The pythonanywhere system recognize this and consider it a sign that my app has crushed and so it pushes it down and reload. The result of this is that it's almost impossible to write code directly online for extensive periods. Any idea on why the TODO element could not be working properly? Or better, how to disable it? thanks, Giacomo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] CAS not working
Hello, I have a problem in using the web2py CAS service. I have created a cas_provider and a cas_client. I have accessed to cas_client /cas_client from here went to /cas_client/default/user/login?_next=/cas_client/default/index and been redirected to /cas_provider/default/user/cas/login?service=https://.../cas_client/default/user/login from here I went to the cas_provider page for registering and I have registered. in the cas_provider database both auth_user and auth_cas have been populated. Login and logout in cas_provider gives no problem. But when I try to login or logout in cas_client I get an EOFError. And auth_user in cas_client has not been populated. I am not sure if it is related but also when I try to call directly /cas_client/default/user/register I get a 404. Thanks for help, Giacomo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.