Not a problem and thanks for the clarification. It's nice to get to know some more of the API.
Paul On Wed, Jan 28, 2009 at 7:43 AM, Timothy Farrell <tfarr...@swgen.com> wrote: > > I missed the third line to see where you assigned it. Oops. > > The web2py version is in fileutils.py and is not actually normally in > the execute environment. I got ahead of myself. It looks like this. > > def up(path): > return os.path.dirname(os.path.normpath(path)) > > Sorry for any confusion. > > -tim > > Paul Eden wrote: > > Very interesting! I didn't know that up() was a web2py function. > > > > I just set it as an alias to os.path.dirname on this line: > > > > up=os.path.dirname > > > > Here is a version then that does not use up() so there are no naming > > conflicts. > > > > import os > > import sys > > aa=os.path.dirname > > sys.path.append(aa(aa(aa(os.path.abspath(__file__))))) > > from gluon.sql import drivers > > > > Paul > > > > On Wed, Jan 28, 2009 at 7:10 AM, Timothy Farrell <tfarr...@swgen.com > > <mailto:tfarr...@swgen.com>> wrote: > > > > > > Note to those unfamiliar: > > > > up() is a web2py function, not a Python function. It will only > > work in > > models and controllers. > > > > -tim > > > > Paul Eden wrote: > > > This version actually works. > > > > > > import os > > > import sys > > > up=os.path.dirname > > > sys.path.append(up(up(up((os. > > > path.abspath(__file__)))))) > > > > > > from gluon.sql import drivers > > > > > > Sorry, I didn't test the last post. > > > > > > Paul > > > > > > > > > On Wed, Jan 28, 2009 at 6:27 AM, Paul Eden <benchl...@gmail.com > > <mailto:benchl...@gmail.com> > > > <mailto:benchl...@gmail.com <mailto:benchl...@gmail.com>>> wrote: > > > > > > Here's a slightly easier way. > > > > > > import os > > > import sys > > > sys.path.append(os.path.dirname(os.path.dirname(__file__))) > > > > > > from gluon.sql import drivers > > > > > > check out the documentation on os.path.dirname > > > <http://docs.python.org/library/os.path.html> > > > > > > Paul > > > > > > > > > On Wed, Jan 28, 2009 at 3:19 AM, billf > > > <billferr...@blueyonder.co.uk > > <mailto:billferr...@blueyonder.co.uk> > > > <mailto:billferr...@blueyonder.co.uk > > <mailto:billferr...@blueyonder.co.uk>>> wrote: > > > > > > > > > I know this is really python but I am writing a test.py > > for the > > > proposed plugin/db stuff where test.py is located in > > > web2py/plugin/ > > > db. In test.py I want to import from gluon.sql. > > > > > > I've managed to do this by appending an item to sys.path > by: > > > > > > gluonpath=__file__.replace('.pyc','.py') > > > gluonpath=gluonpath.replace('.py','') > > > gluonpath=gluonpath.replace(__name__,'../..') > > > sys.path.append(gluonpath) > > > from gluon.sql import drivers > > > > > > ... but there must be a more elegant way. can anyone > > help me > > > out of > > > my ignorance please. > > > > > > > > > > > > > > > -- > > > Best Regards, > > > > > > Paul Eden > > > > > > "...and a little looking out for the other guy too." > > > - Mr. Smith > > > > > > > > > > > > > > > -- > > > Best Regards, > > > > > > Paul Eden > > > > > > "...and a little looking out for the other guy too." > > > - Mr. Smith > > > > > > > > > > > -- > > Timothy Farrell <tfarr...@swgen.com <mailto:tfarr...@swgen.com>> > > Computer Guy > > Statewide General Insurance Agency (www.swgen.com > > <http://www.swgen.com>) > > > > > > > > > > > > > > -- > > Best Regards, > > > > Paul Eden > > > > "...and a little looking out for the other guy too." > > - Mr. Smith > > > > > > > -- > Timothy Farrell <tfarr...@swgen.com> > Computer Guy > Statewide General Insurance Agency (www.swgen.com) > > > > > -- Best Regards, Paul Eden "...and a little looking out for the other guy too." - Mr. Smith --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---