pythonically speaking, web2py is not a package, gluon is. you just have to 
have gluon in sys.path.

On Wednesday, May 25, 2016 at 12:22:20 PM UTC+2, Remco Boerma wrote:
>
> Hey folks. 
>
> I want to use pydal and the validators of web2py in a virtualenv. I am 
> working on a seperate script and not a full blown web2py application. So no 
> web, just console. 
> Since pip install web2py produces nothing useful i do this: 
>
> cd env
> bin/activate
> cd lib/site-packages
> git clone https://github.com/web2py/web2py
> echo '' > web2py/__init__.py
>
>
> In  the python script i can now do the following: 
>
> import sys, os.path , web2py
>
> from pydal import DAL , Field
>
> w2p_folder, _ = os.path.split(web2py.__file__) 
>
>
> sys.path.extend((w2p_folder, os.path.join(w2p_folder,'gluon')))
> from gluon.validators import IS_IN_DB
> db = DAL('sqlite://somedb_effdt.db')
>
>
> It works, but it feels dirty. Some parts of web2py need direct access to 
> gluon and others to the packages inside gluon. 
> Anyone have a cleaner working solution or would this be as good as it 
> gets? 
>  
> Regards, 
> Remco Boerma
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to