A Dijous 26 Juny 2008, [EMAIL PROTECTED] va escriure:
> Could you publish how do you do the import of the images to the database
> please?
I use KTiny client side API. For example, the following script could be used
to upload all PNG images of the given directory as attachments (attached to
no document, by the way, but you get the idea).
#!/usr/bin/python
import os
import sys
import glob
import base64
import rpc
if len(sys.argv) != 3:
print 'loader.py database directory'
sys.exit(1)
rpc.session.login( 'http://admin:[EMAIL PROTECTED]:8069', sys.argv[1] )
files = glob.glob(sys.argv[2] + "/*.png")
for x in files:
print "Loading file: ", x
fields = {}
fields['name'] = os.path.split(x)[1]
fields['datas'] = base64.encodestring(open(x, 'rb').read())
rpc.session.execute('/object', 'execute', 'ir.attachment', 'create',
fields )
If you don't want to depend on KTiny you could probably do something similar
with GTK rpc client module or with plain xmlrpc, which is pretty simple too.
The advantage of using this code is that you can use Net-RPC just by
changing 'http://' with 'socket://' and the appropiate port, of course.
>
> Thanks.
>
> Luisg
>
>
>
>
> _______________________________________________
> Tinyerp-users mailing list
> http://tiny.be/mailman/listinfo/tinyerp-users
--
Albert Cervera i Areny
http://www.NaN-tic.com
_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman/listinfo/tinyerp-users