Hi again all! Upon further trying to expand and experiment I stuck at something that maybe I need to be clarified on or I'm doing wrong.
Basically what I did is create a "store.py" in that I specified the database exactly like it was in db.py (except. Then what I did in menu.py was simply change: response.menu = menu_rec(db(db.store_catalog).select().as_trees()) to response.menu = menu_rec(store(store.store_catalog).select().as_trees()) However it immediately errors out in the shell claiming "store" is not defined, as well as producing a ticket with the same error. When I change it back to the original "response.menu" and I run the shell I can access store.whatever. What am I not getting about this or is it not possible? >From the examples I've looked at it seems as though it should work. Can I get pointed in the right direction or thinking on this please? Thanks! On Thursday, January 23, 2014 6:40:53 AM UTC-6, web2pygroup wrote: > > After disabling the key constraints none of those errors about it have > appeared. I am grateful for the assistance and will return it anyway I > can. I will post a summary here for anyone attempting this also. Thanks a > million! > > On Wednesday, January 22, 2014 12:03:26 PM UTC-6, web2pygroup wrote: >> >> That works great, thank you!!! My only remaining question is that when I >> try to edit the first record "main" in the appadmin I get the foreign key >> error. I read here -> >> https://groups.google.com/forum/#!topic/web2py/klspqXpha4E <- about how >> to disable it. Wasn't sure if I should do that or not... The other >> records do not act up when changed, just that one so I'm sure I could work >> around that but, just in case someone else manages the site... I'm not >> sure. Thoughts? >> >> On Tuesday, January 21, 2014 11:03:46 PM UTC-6, Massimo Di Pierro wrote: >>> >>> Sorry typo. Let's try again: >>> >>> db.define_table('store_catalog', >>> Field('title'), >>> Field('slug',requires=IS_SLUG(),compute=lambda row: >>> IS_SLUG.urlify(row.titl\ >>> e)), >>> Field('parent_id','reference store_catalog')) >>> >>> id1 = db.store_catalog.insert(title='main') >>> id2 = db.store_catalog.insert(title='one',parent_id=id1) >>> id3 = db.store_catalog.insert(title='two',parent_id=id2) >>> >>> def menu_rec(items): return >>> [(x.title,None,URL('action',args=x.slug),menu_rec(x\ >>> .children)) for x in items or []] >>> response.menu = menu_rec(db(db.store_catalog).select().as_trees()) >>> print response.menu >>> >>> On Tuesday, 21 January 2014 12:17:19 UTC-6, web2pygroup wrote: >>>> >>>> Here's what I've tried so far and here's the results if it helps any to >>>> get me on the right track, plus I hope this helps someone else looking for >>>> this to because this is something very commonly done in PHP. >>>> >>>> I have tried changing this: >>>> response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]]) >>>> >>>> to this: >>>> response.menu3[-1]+=([(T(subcat.subcategory)), False, 'link',]) >>>> >>>> Which changes the output in the shell to: >>>> [<lazyT 'Catalog'>, >>>> False, >>>> '', >>>> [<lazyT 'Animals'>, >>>> False, >>>> 'link', >>>> <lazyT 'Dogs'>, >>>> False, >>>> 'link', >>>> <lazyT 'Cats'>, >>>> False, >>>> 'link']] >>>> >>>> Which obviously isn't correct. >>>> >>>> Continuing: >>>> >>>> original: >>>> response.menu3[-1]+=([[(T(subcat.subcategory)), False, 'link',]]) >>>> >>>> to this: >>>> response.menu3+=([[(T(subcat.subcategory)), False, 'link',]]) >>>> >>>> Gives this in the shell output: >>>> [<lazyT 'Catalog'>, >>>> False, >>>> '', >>>> [<lazyT 'Animals'>, False, 'link'], >>>> [<lazyT 'Dogs'>, False, 'link'], >>>> [<lazyT 'Cats'>, False, 'link']] >>>> >>>> Again obviously incorrect. Continuing: >>>> >>>> original: >>>> response.menu3+=([[(T(subcat.subcategory)), False, 'link',]]) >>>> >>>> changed: >>>> response.menu3[-1]+=((T(subcat.subcategory)), False, 'link',) >>>> >>>> Shell output shows: >>>> [<lazyT 'Catalog'>, >>>> False, >>>> '', >>>> [<lazyT 'Animals'>, >>>> False, >>>> 'link', >>>> <lazyT 'Dogs'>, >>>> False, >>>> 'link', >>>> <lazyT 'Cats'>, >>>> False, >>>> 'link']] >>>> >>>> I tried additional variations but, not sure how much space we have here >>>> to keep going with my 2 weeks worth of work. Essentially the end result >>>> is >>>> the same a bracket missing to seperate the subcategories. I've been able >>>> to modify and add to lists before, however I've never really experienced a >>>> situation where the negative slice appears to be ignored (removing the >>>> bracket at the end of dogs and beginning of cats as it is doing for the >>>> main category Animals as can be seen), even removed the negative slice >>>> ([-1]) for the main categories iteration and when I do it clearly shows >>>> that it is actually doing the negative slice properly because the brackets >>>> come back at the end of Animals, unlike the subcategories that do not >>>> appear to be removing the bracket(s) >>>> >>>> >>>> On Monday, January 20, 2014 2:33:50 PM UTC-6, web2pygroup wrote: >>>>> >>>>> >>>>> Hi all, >>>>> >>>>> I have been trying for a little over 2 weeks to figure this out... >>>>> >>>>> I'm trying to generate a menu that drops down, I have been able to >>>>> statically create it by overwriting sample app that has the same drop >>>>> down >>>>> menu like the web2py.com site. >>>>> >>>>> I have this in my db.py: >>>>> db.define_table('store_catalog', >>>>> Field('maincategory', 'string'), >>>>> Field('subcategory', 'string'), >>>>> Field('description', 'text')) >>>>> >>>>> >>>>> in my menu.py I have gotten this so far: >>>>> response.menu=[] >>>>> response.menu.append([T('Catalog'), False, '', >>>>> [(T('%s' % menucatchoice['maincategory']), False, >>>>> 'link', >>>>> [(T('%s' % menucatchoice['subcategory']), False, >>>>> 'link'),]) for menucatchoice in rows ] ]) >>>>> >>>>> It gets me a drop down menu except that for each subcategory it >>>>> repeats adding it to the main category. Let's say there is only 1 main >>>>> category and 2 subs that go after that >>>>> Catalog (this just shows with the caret next to it as intended) >>>>> MainCategory >>>>> Sub >>>>> Sub >>>>> What I have does put the "Catalog" for the first but, what I get is: >>>>> MainCategory >>>>> (blank) >>>>> MainCategory(don't want this it's being repeated) >>>>> Subcategory >>>>> MainCategory(and this one is also a repeat) >>>>> Subcategory >>>>> >>>>> I have tried to break out the response.menu with so many different >>>>> .appends it's not funny. I have also tried adding the "[-1]". This was >>>>> the closest I have gotten to what I want it to look like. I'm at an >>>>> absolute loss on this, any and all help would be greatly appreciated. >>>>> >>>> -- 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/groups/opt_out.