fabfile ATM is a show-off, and we can't put in there code related to an app which doesn't exist :P We can't pin each and every thread a "useful" information is written, as I really don't see how 40 pinned threads will contribute to web2py's knowledge for - and especially - newbies.
IMHO at most it should land on the book (deployment chapter), which everyone is highly encouraged to contribute, and doesn't need any python-web2py superpower to do so. On Tuesday, August 30, 2016 at 9:54:26 PM UTC+2, Richard wrote: > > To be added to the fabfile.py of web2py maybe?! > > On Tue, Aug 30, 2016 at 3:53 PM, Richard Vézina <ml.richa...@gmail.com > <javascript:>> wrote: > >> Don't have privileges, but this is a good thread and should be marked as >> informative somehow... >> >> Richard >> >> On Tue, Aug 30, 2016 at 2:24 PM, Dave S <snide...@gmail.com <javascript:> >> > wrote: >> >>> >>> >>> On Tuesday, August 30, 2016 at 6:58:43 AM UTC-7, Richard wrote: >>>> >>>> Seems alright do you have issue with this? I would put a blank line >>>> between model definition and the "if isempty()". >>>> >>>> I production, once the system get initialize you should remove those >>>> populating fixture to save execution time as the get execute at each >>>> request. >>>> >>>> What could wizely do is put all the populating fixtures in a models >>>> file or controller file function that you delete or comment out once you >>>> populate you empty new database instance. Putting it in a function >>>> controller file wouldn't requires you to delete them as you will never >>>> call >>>> this controller file later on and if can by mistake it will not do >>>> anything. But depend of the size fo the populated data set the call of a >>>> function could lead to a time out from the web server which prevent >>>> completion of populating data. So you have to evaluate if it has chance or >>>> not to complete properly. You can split the populating process into a >>>> couple of function call so yo don't reach time out. >>>> >>>> >>> Or give the function a dummy argument >>> def func(dummy=True): >>> ... >>> >>> >>> and then invoke it with -S from the command line. This parallels >>> Niphlod's advice for setting up the initial copy of a recurring task. (The >>> dummy arg keeps the function from being exposed as a URL.) >>> >>> Good luck >>>> >>>> Richard >>>> >>>> >>> /dps >>> >>> >>> >>>> >>>> >>>> On Tue, Aug 30, 2016 at 9:34 AM, Ben Lawrence <benla...@gmail.com> >>>> wrote: >>>> >>>>> At the moment to pre-populate a database, I place this in the db.py >>>>> model file: >>>>> >>>>> db.define_table('color', >>>>> Field('name','string'), >>>>> Field('code','string'), >>>>> format='%(name)s') >>>>> if db(db.color).isempty(): >>>>> # create instance of table >>>>> for k,v in >>>>> dict(lime="#00FF00",red="#FF0000",black="#000000",orange="#FFA500",\ >>>>> blue="#0000FF", yellow="#FFFF00", fuchsia="#FF00FF", >>>>> aqua="#00FFFF",\ >>>>> maroon="#800000", green="#008000", navy="#000080", >>>>> olive="#808000",\ >>>>> purple="#800080", teal="#008080", gray="#808080", >>>>> silver="#C0C0C0").items(): >>>>> db.color.insert(name=k,code=v) >>>>> >>>>> >>>>> >>>>> I wonder if this is the best way to pre-populate a database? >>>>> >>>>> thanks, >>>>> Ben >>>>> >>>>> -- >>>>> 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+un...@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+un...@googlegroups.com <javascript:>. >>> 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.