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> 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>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

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to