I tried a while to add to system path, but some caused a little bit of grief where importing one module that had dependancies on other modules that were more focused on web use would force me to modify some gluon modules, then i had to write a script to update web2py modules everytime i upgraded... but woth the 'new dal', i have absolutly no more issues (can use as is).
I see what you mean about testing statements and the like. I found it easier to simply start new pages by importing the modules I use and pointing to the classes i need. For example, I use dal.py just about everywhere now (at first was to create the habit and get used to it, now i just find a quick and dirty sqlite db way too useful to be without). So any singleton script quick script to test something will start with from [...].gluon.dal import DAL from [...].gluon.dal import Field (and more if need be) if larger set of scripts, i model this way (for me this worked the best) root__ |__/storage | |____/storageHandler.py * creates the db + tables (has | the connection string to | SQLite) - this way, only | one py module is creating | tables | |___/someBaseModule.py * he gets 'db', every over module | extends this one (so they can | simply use 'self.db' anywhere) | and is a good place for | shortcuts (i.e. scripts that | extend it can make use of | a statement like: | | select=self.myComplicatedSelect | | so, i can be lazy and do | select('this') or select('that') | |___/someMain.py * this one sets the ENV, calls | storageHandler.py (just the | one time which will return | 'db'), will create a reference | to someBaseModule, will kick | off scripts, or an automation, | or can take args, etc... | |___/*.py * here is where the fun happens,it already has someBaseModule's constructor, so it can start right away without worrying about anything and can start using 'self.db' as well... from root.someBaseModule import aClass className(aClass): def someFuction(self): db=self.db db.this... db.that... etcetera anyways, I found more benefit in doing this than having gluon in system path... Mart :) On Apr 30, 4:10 am, luckysmack <luckysm...@gmail.com> wrote: > mostly just for testing things and learning web2py. for example when > going through the book and learning things, to follow along. or when i > read a tute online somewhere. but also for the same reason the python > shell is there, to test statements and see if syntax is correct and > the like. I want to be able to do the same with the gluon code. > > On Apr 29, 6:03 pm, Jonathan Lundell <jlund...@pobox.com> wrote: > > > > > > > > > On Apr 29, 2011, at 5:56 PM, luckysmack wrote: > > > > when i append gluon to the sys.path and try to import it doesnt work > > > because its unable to find it. I am installing web2py via pip. THanks > > > for the help too guys. appreciate it. > > > What exactly are you trying to import? > > > > On Apr 29, 12:01 pm, José Luis Redrejo Rodríguez <jredr...@debian.org> > > > wrote: > > >> 2011/4/29 Jonathan Lundell <jlund...@pobox.com>: > > > >>> On Apr 29, 2011, at 7:19 AM, luckysmack wrote: > > > >>>> Yea im using 11.04 which just released. So its probably just that it > > >>>> hasnt been updated yet. ill check out that one package until it shows > > >>>> up in the repo and try to update to that. I know theyre all in line > > >>>> with each other but ive seen a few times where a package showed up in > > >>>> debian but not ubuntu, not sure what they were but i think they were > > >>>> pretty esoteric packages. Anyways, thanks. Ill just get the linked > > >>>> one. > > > >>> The actual problem may be different from how it appears. Adding the > > >>> path to gluon to sys.path ought to work fine as far as it goes, but > > >>> web2py generally expects to be started from its own directory. > > > >>> What happens exactly when you add gluon to sys.path and attempt an > > >>> import? > > > >> What you can expect: you have available all the gluon modules and > > >> functions. Remember you can use dal or the html parser for non-web2py > > >> projects. > > > >> On the other hand, you can start web2py from any directory passing the > > >> -f parameter. Having gluon available in the sys.path you only need to > > >> pass to web2py the applications directory path. No other files or > > >> directories are needed. That's the way Debian package works and there > > >> are not known problems with it. > > > >> Regards. > > > >>>> On Apr 29, 1:45 am, José Luis Redrejo Rodríguez <jredr...@debian.org> > > >>>> wrote: > > >>>>> 2011/4/29 luckysmack <luckysm...@gmail.com>: > > > >>>>>> python-gluon and python-web2py dont seem to be in the ubuntu repos. I > > >>>>>> found a .deb file herehttp://pkgs.org/package/python-gluonbutiwant > > >>>>>> to get some feedback first if anyone knows a better way. a few quick > > >>>>>> searches didnt show anything about adding a repo to ubuntu to make it > > >>>>>> available. > > > >>>>> Ubuntu is a debian derivative. Ubuntu people sync their packages from > > >>>>> Debian unstable repository periodically. > > >>>>> Web2py packages are in Debian since less than a couple of weeks. > > >>>>> Ubuntu released a new version yesterday, so I supposse they'll take > > >>>>> the packages soon. The packages that are in Debian are exactly the > > >>>>> same that Ubuntu will take, so you can use them if you're using a > > >>>>> recent Ubuntu version, because Ubuntu is not going to modify them. > > > >>>>> Regards. > > >>>>> José L. > > > >>>>>> On Apr 28, 10:50 pm, José Luis Redrejo Rodríguez > > >>>>>> <jredr...@debian.org> > > >>>>>> wrote: > > >>>>>>> 2011/4/29 luckysmack <luckysm...@gmail.com>: > > > >>>>>>>> Pretty much like the title says. This is also for things like when > > >>>>>>>> i > > >>>>>>>> open up a i/b/python shell, it would be cool to just be able to run > > >>>>>>>> 'import gluon' or 'from gluon import foo'. Im sure this would also > > >>>>>>>> have other benefits as well, but im not sure. I tried doing 'import > > >>>>>>>> sys' and 'sys.path.append("/srv/sites/web2py/gluon")' but that > > >>>>>>>> didnt > > >>>>>>>> seem to work. i also tried it without the/gluon part. Is it worth > > >>>>>>>> it > > >>>>>>>> to do this? otherwise i can get the effect by opening a terminal > > >>>>>>>> and > > >>>>>>>> going to the web2py directory, opening the python shell and > > >>>>>>>> importing > > >>>>>>>> like that. This culd also be handy when running python scripts that > > >>>>>>>> are in different places on the system and wanting to be able to > > >>>>>>>> import > > >>>>>>>> something from gluon. > > > >>>>>>> Using a Debian distribution (or any of its derivatives) you can > > >>>>>>> install the debian package python-gluon > > >>>>>>> (http://packages.qa.debian.org/w/web2py.html) . When installing it, > > >>>>>>> gluon is available in the python path. > > > >>>>>>> Regards.