Yeah exactly ... that is the reason for question. Wont it be a good idea to define the urls,sessions and app in a separate file say config.py and then add them to web.ctx.urls, web.ctx.session, web.ctx.app in config.py
In the main code.py we import this config.py file so that the config code runs and in all other files use web.ctx.urls, web.ctx.sessions and web.ctx.app Cheers PK On Oct 28, 4:44 am, Tomás Acauan Schertel <[email protected]> wrote: > As fas as I know, each file will act as an application. > In cookbook' s example you can see that both files has a web.application > declared. > > -- > Tomás Schertel > ---------------------------------------------- > Linux Registered User #304838 > Arch Linux Userhttp://www.archlinux-br.org/ > ---------------------------------------------- > > > > > > > > On Thu, Oct 27, 2011 at 19:42, Dexter <[email protected]> wrote: > > Thanks for the replies guys ... few more doubts though ... > > > @Tomas > > Do sub apps mean using more than one file and nothin more ... > > I would like to clear that I have just one app ... I just want to > > separate the classes into different files and not define different > > app = web.application(urls, globals(),autoreload=False) > > > @Sergei > > That means I wont have access to to the form data in render in I dont > > define it like ? > > render._keywords['globals']['render'] = render > > > Cheers > > PK > > > On Oct 26, 11:10 pm, Tomás Acauan Schertel <[email protected]> > > wrote: > > > Dexter, > > > > Take a look here:http://webpy.org/cookbook/sessions_with_subapp > > > This page shows how you can work with session and sub applications (more > > > than one file). > > > > -- > > > Tomás Schertel > > > ---------------------------------------------- > > > Linux Registered User #304838 > > > Arch Linux Userhttp://www.archlinux-br.org/ > > > ---------------------------------------------- > > > > On Wed, Oct 26, 2011 at 10:30, Dexter <[email protected]> wrote: > > > > Hi > > > > > I have started writing an application in web.py > > > > The main code.py page consists of numerous classes now and the > > > > different classes have content like forms to be rendered > > > > > The page has become quite crowded. What is the best practice to > > > > organise webpy code. I thought that may putting the different classes > > > > in different files is a good idea. However that causes the DBSession > > > > stores and the commonly used decorators to be inaccessible to the > > > > classes. > > > > > I can define the > > > > DBstore = web.session.DBStore(DB, 'sessions') > > > > dbsession = web.session.Session(app, DBstore, initializer={'count': > > > > 0}) > > > > > in a separate file and import it both in code.py and the other > > > > classes.py > > > > > However I am not sure if then the same session remains globally used. > > > > How can I make some objects globally the same > > > > Should I use something like web.ctx > > > > > One more question > > > > Can anyone explain what is the significance of > > > > render._keywords['globals']['render'] = render > > > > at > > > >http://webpy.org/skeleton/0.3 > > > > > in view.py > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "web.py" group. > > > > To post to this group, send email to [email protected]. > > > > To unsubscribe from this group, send email to > > > > [email protected]. > > > > For more options, visit this group at > > > >http://groups.google.com/group/webpy?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "web.py" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/webpy?hl=en. -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
