[MERGE] wsgification and more, thanks to vmt

bzr revid: al@openerp.com-20110925000221-hctc1t18njh98oal
This commit is contained in:
Antony Lesuisse 2011-09-25 02:02:21 +02:00
commit 828d12b07c
8 changed files with 31 additions and 40 deletions

View File

@ -21,14 +21,15 @@
from report.interface import report_int from report.interface import report_int
import netsvc import netsvc
import openerp.pooler
class report_artistlot(report_int): class report_artistlot(report_int):
def __init__(self, name): def __init__(self, name):
report_int.__init__(self, name) report_int.__init__(self, name)
def create(self, cr, uid, ids, datas, context): def create(self, cr, uid, ids, datas, context):
service = netsvc.LocalService("object_proxy") pool = pooler.get_pool(cr.dbname)
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['artist_id']) lots = pool.get('auction.lots').read(cr, uid, ids, ['artist_id'])
artists = [] artists = []
for lot in lots: for lot in lots:
if lot['artist_id'] and lot['artist_id'] not in artists: if lot['artist_id'] and lot['artist_id'] not in artists:

View File

@ -20,15 +20,15 @@
############################################################################## ##############################################################################
from report.interface import report_int from report.interface import report_int
import netsvc import openerp.pooler
class auction_seller(report_int): class auction_seller(report_int):
def __init__(self, name): def __init__(self, name):
report_int.__init__(self, name) report_int.__init__(self, name)
def create(self, cr, uid, ids, datas, context): def create(self, cr, uid, ids, datas, context):
service = netsvc.LocalService("object_proxy") pool = openerp.pooler.get_pool(cr.dbname)
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['bord_vnd_id']) lots = pool.get('auction.lots').read(cr, uid, ids, ['bord_vnd_id'])
bords = {} bords = {}
for l in lots: for l in lots:
@ -37,7 +37,7 @@ class auction_seller(report_int):
new_ids = bords.keys() new_ids = bords.keys()
parts = {} parts = {}
partners = service.execute(cr.dbname, uid, 'auction.deposit', 'read', new_ids, ['partner_id']) partners = pool.get('auction.deposit').read(cr, uid, new_ids, ['partner_id'])
for l in partners: for l in partners:
if l['partner_id']: if l['partner_id']:
parts[l['partner_id'][0]]=True parts[l['partner_id'][0]]=True

View File

@ -32,10 +32,8 @@ class report_custom(report_rml):
report_rml.__init__(self, name, table, tmpl, xsl) report_rml.__init__(self, name, table, tmpl, xsl)
def create_xml(self, cr, uid, ids, datas, context=None): def create_xml(self, cr, uid, ids, datas, context=None):
service = netsvc.LocalService("object_proxy") lots = self.pool.get('auction.lots').read(cr, uid , ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
auction = self.pool.get('auction.dates').read(cr, uid, [lots[0]['auction_id'][0]])[0]
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
unsold = comm = emp = paid = unpaid = 0 unsold = comm = emp = paid = unpaid = 0
est1 = est2 = adj = 0 est1 = est2 = adj = 0
@ -75,7 +73,7 @@ class report_custom(report_rml):
debit = adj debit = adj
costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_seller_costs', ids) costs = self.pool.get('auction.lots').compute_seller_costs(cr, uid, ids)
for cost in costs: for cost in costs:
debit += cost['amount'] debit += cost['amount']

View File

@ -141,9 +141,8 @@ class auction_lots_send_aie(osv.osv_memory):
def _photos_send(cr, uid, uname, passwd, did, ids): def _photos_send(cr, uid, uname, passwd, did, ids):
service = netsvc.LocalService("object_proxy")
for (ref,id) in ids: for (ref,id) in ids:
datas = service.execute(cr.db_name, uid, 'auction.lots', 'read', [id], ['name','image']) datas = self.pool.get('auction.lots').read(cr, uid, [id], ['name','image'])
if len(datas): if len(datas):
bin = base64.decodestring(datas[0]['image']) bin = base64.decodestring(datas[0]['image'])
fname = datas[0]['name'] fname = datas[0]['name']
@ -186,8 +185,7 @@ class auction_lots_send_aie(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
service = netsvc.LocalService("object_proxy") lots = self.pool.get('auction.lots').read(cr, uid, context.get('active_ids',[]), ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ'])
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids',[]), ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ'])
lots_ids = [] lots_ids = []
datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates'])
for l in lots: for l in lots:

View File

@ -132,9 +132,8 @@ class auction_lots_pay(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
import pickle import pickle
service = netsvc.LocalService("object_proxy")
datas = self.read(cr, uid, ids[0],['uname','password','dates']) datas = self.read(cr, uid, ids[0],['uname','password','dates'])
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','obj_price']) lots = self.pool.get('auction.lots').read(cr, uid, context['active_ids'], ['obj_num','obj_price'])
args = pickle.dumps(lots) args = pickle.dumps(lots)
self._catalog_send(datas['uname'], datas['password'], datas['dates'], args) self._catalog_send(datas['uname'], datas['password'], datas['dates'], args)
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}

View File

@ -49,9 +49,8 @@ class auction_lots_invoice(osv.osv_memory):
if context is None: if context is None:
context = {} context = {}
res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context)
service = netsvc.LocalService("object_proxy") lots = self.pool.get('auction.lots').read(cr, uid, context.get('active_ids', []))
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', [])) auction = self.pool.get('auction.dates').read(cr, uid, [lots[0]['auction_id'][0]])[0]
auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
price = 0.0 price = 0.0
price_topay = 0.0 price_topay = 0.0
@ -59,7 +58,7 @@ class auction_lots_invoice(osv.osv_memory):
for lot in lots: for lot in lots:
price_lot = lot['obj_price'] or 0.0 price_lot = lot['obj_price'] or 0.0
costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_buyer_costs', [lot['id']]) costs = self.pool.get('auction.lots').compute_buyer_costs(cr, uid, [lot['id']])
price_lot += costs['amount'] price_lot += costs['amount']
price += price_lot price += price_lot
@ -68,7 +67,7 @@ class auction_lots_invoice(osv.osv_memory):
raise osv.except_osv(_('UserError'), _('Two different buyers for the same invoice !\nPlease correct this problem before invoicing')) raise osv.except_osv(_('UserError'), _('Two different buyers for the same invoice !\nPlease correct this problem before invoicing'))
uid = lot['ach_uid'][0] uid = lot['ach_uid'][0]
elif lot['ach_login']: elif lot['ach_login']:
refs = service.execute(uid, 'res.partner', 'search', [('ref','=',lot['ach_login'])]) refs = self.pool.get('res.partner').search(cr, uid, [('ref','=',lot['ach_login'])])
if len(refs): if len(refs):
uid = refs[-1] uid = refs[-1]
if 'ach_pay_id' in lot and lot['ach_pay_id']: if 'ach_pay_id' in lot and lot['ach_pay_id']:
@ -105,7 +104,6 @@ class auction_lots_invoice(osv.osv_memory):
""" """
if context is None: if context is None:
context = {} context = {}
service = netsvc.LocalService("object_proxy")
datas = {'ids' : context.get('active_ids',[])} datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['number','ach_uid']) res = self.read(cr, uid, ids, ['number','ach_uid'])
res = res and res[0] or {} res = res and res[0] or {}

View File

@ -455,7 +455,7 @@ class openerp_dav_handler(dav_interface):
def get_cr(self, uri, allow_last=False): def get_cr(self, uri, allow_last=False):
""" Split the uri, grab a cursor for that db """ Split the uri, grab a cursor for that db
""" """
pdb = self.parent.auth_proxy.last_auth pdb = self.parent.auth_provider.last_auth
dbname, uri2 = self.get_db(uri, rest_ret=True, allow_last=allow_last) dbname, uri2 = self.get_db(uri, rest_ret=True, allow_last=allow_last)
uri2 = (uri2 and uri2.split('/')) or [] uri2 = (uri2 and uri2.split('/')) or []
if not dbname: if not dbname:
@ -463,10 +463,10 @@ class openerp_dav_handler(dav_interface):
# if dbname was in our uri, we should have authenticated # if dbname was in our uri, we should have authenticated
# against that. # against that.
assert pdb == dbname, " %s != %s" %(pdb, dbname) assert pdb == dbname, " %s != %s" %(pdb, dbname)
res = self.parent.auth_proxy.auth_creds.get(dbname, False) res = self.parent.auth_provider.auth_creds.get(dbname, False)
if not res: if not res:
self.parent.auth_proxy.checkRequest(self.parent, uri, dbname) self.parent.auth_provider.checkRequest(self.parent, uri, dbname)
res = self.parent.auth_proxy.auth_creds[dbname] res = self.parent.auth_provider.auth_creds[dbname]
user, passwd, dbn2, uid = res user, passwd, dbn2, uid = res
db,pool = pooler.get_db_and_pool(dbname) db,pool = pooler.get_db_and_pool(dbname)
cr = db.cursor() cr = db.cursor()

View File

@ -40,7 +40,7 @@ from dav_fs import openerp_dav_handler
from tools.config import config from tools.config import config
from DAV.WebDAVServer import DAVRequestHandler from DAV.WebDAVServer import DAVRequestHandler
from service import http_server from service import http_server
from service.websrv_lib import HTTPDir, FixSendError, HttpOptions from service.websrv_lib import FixSendError, HttpOptions
from BaseHTTPServer import BaseHTTPRequestHandler from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse import urlparse
import urllib import urllib
@ -174,11 +174,11 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
pass pass
elif self.close_connection == 1: # close header already sent elif self.close_connection == 1: # close header already sent
pass pass
else: elif headers and self.headers.get('Connection',False) == 'Keep-Alive':
if headers is None: headers['Connection'] = 'keep-alive'
headers = {}
if self.headers.get('Connection',False) == 'Keep-Alive': if headers is None:
headers['Connection'] = 'keep-alive' headers = {}
DAVRequestHandler.send_body(self, DATA, code=code, msg=msg, desc=desc, DAVRequestHandler.send_body(self, DATA, code=code, msg=msg, desc=desc,
ctype=ctype, headers=headers) ctype=ctype, headers=headers)
@ -572,7 +572,7 @@ try:
conf = OpenDAVConfig(**_dc) conf = OpenDAVConfig(**_dc)
handler._config = conf handler._config = conf
reg_http_service(HTTPDir(directory,DAVHandler,DAVAuthProvider())) reg_http_service(directory, DAVHandler, DAVAuthProvider)
logging.getLogger('webdav').info("WebDAV service registered at path: %s/ "% directory) logging.getLogger('webdav').info("WebDAV service registered at path: %s/ "% directory)
if not (config.get_misc('webdav', 'no_root_hack', False)): if not (config.get_misc('webdav', 'no_root_hack', False)):
@ -592,9 +592,7 @@ try:
# the StaticHttpHandler can find its dir_path. # the StaticHttpHandler can find its dir_path.
config.misc.setdefault('static-http',{})['dir_path'] = dir_path config.misc.setdefault('static-http',{})['dir_path'] = dir_path
if reg_http_service(HTTPDir('/', DAVStaticHandler)): reg_http_service('/', DAVStaticHandler)
logging.getLogger("web-services").info("WebDAV registered HTTP dir %s for /" % \
(dir_path))
except Exception, e: except Exception, e:
logging.getLogger('webdav').error('Cannot launch webdav: %s' % e) logging.getLogger('webdav').error('Cannot launch webdav: %s' % e)
@ -613,8 +611,7 @@ def init_well_known():
reps['/'+uri] = path reps['/'+uri] = path
if int(num_svcs): if int(num_svcs):
if http_server.reg_http_service(HTTPDir('/.well-known', RedirectHTTPHandler)): reg_http_service('/.well-known', RedirectHTTPHandler)
logging.getLogger("web-services").info("Registered HTTP redirect handler at /.well-known" )
init_well_known() init_well_known()
@ -641,7 +638,7 @@ def init_principals_redirect():
dbname = config.get('db_name', False) dbname = config.get('db_name', False)
if dbname: if dbname:
PrincipalsRedirect.redirect_paths[''] = '/webdav/%s/principals' % dbname PrincipalsRedirect.redirect_paths[''] = '/webdav/%s/principals' % dbname
reg_http_service(HTTPDir('/principals', PrincipalsRedirect)) reg_http_service('/principals', PrincipalsRedirect)
logging.getLogger("web-services").info( logging.getLogger("web-services").info(
"Registered HTTP redirect handler for /principals to the %s db.", "Registered HTTP redirect handler for /principals to the %s db.",
dbname) dbname)