summaryrefslogtreecommitdiff
path: root/addons/document
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@tinyerp.com>2009-08-03 09:01:56 +0200
committerFabien Pinckaers <fp@tinyerp.com>2009-08-03 09:01:56 +0200
commit5ebd3bc12cb0940d95dbfeb78e60e5a4ce174d06 (patch)
treefbbea591e5cd0659abc53f92d24adba143dc45f0 /addons/document
parent3472508614e7ee985d8f87faf4e6a658d5bdca56 (diff)
parent738dc7153439aa6a02a35a23449214265547e516 (diff)
merge
bzr revid: fp@tinyerp.com-20090803070156-38o2tyzljrlsuh84
Diffstat (limited to 'addons/document')
-rw-r--r--addons/document/document.py64
-rw-r--r--addons/document/ftpserver/abstracted_fs.py40
-rw-r--r--addons/document/i18n/fr_FR.po76
3 files changed, 124 insertions, 56 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index 585031e1fc5..1a66145a9d8 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -66,8 +66,10 @@ def random_name():
# root: if we are at the first directory of a ressource
#
INVALID_CHARS={'*':str(hash('*')), '|':str(hash('|')) , "\\":str(hash("\\")), '/':'__', ':':str(hash(':')), '"':str(hash('"')), '<':str(hash('<')) , '>':str(hash('>')) , '?':str(hash('?'))}
+
+
class node_class(object):
- def __init__(self, cr, uid, path,object,object2=False, context={}, content=False, type='collection', root=False):
+ def __init__(self, cr, uid, path, object, object2=False, context={}, content=False, type='collection', root=False):
self.cr = cr
self.uid = uid
self.path = path
@@ -92,7 +94,7 @@ class node_class(object):
where.append( ('parent_id','=',self.object.id) )
where.append( ('res_id','=',False) )
if nodename:
- where.append( (fobj._rec_name,'like',nodename) )
+ where.append( (fobj._rec_name,'=',nodename) )
for content in self.object.content_ids:
if self.object2 or not content.include_name:
if content.include_name:
@@ -135,7 +137,7 @@ class node_class(object):
where = []
if nodename:
nodename = self.get_translation(nodename, self.context['lang'])
- where.append(('name','like',nodename))
+ where.append(('name','=',nodename))
if (self.object and self.object.type=='directory') or not self.object2:
where.append(('parent_id','=',self.object and self.object.id or False))
else:
@@ -161,7 +163,7 @@ class node_class(object):
fobj = pool.get('ir.attachment')
vargs = [('parent_id','=',False),('res_id','=',False)]
if nodename:
- vargs.append(('name','like',nodename))
+ vargs.append(('name','=',nodename))
file_ids=fobj.search(self.cr,self.uid,vargs)
res = fobj.browse(self.cr, self.uid, file_ids, context=self.context)
@@ -171,9 +173,9 @@ class node_class(object):
pool = pooler.get_pool(self.cr.dbname)
obj = pool.get(self.object.ressource_type_id.model)
if len(obj.fields_get(self.cr, self.uid, ['dirname'])):
- _dirname_field = 'dirname'
+ _dirname_field = 'dirname'
else:
- _dirname_field = 'name'
+ _dirname_field = 'name'
name_for = obj._name.split('.')[-1]
if nodename and nodename.find(name_for) == 0 :
@@ -186,7 +188,7 @@ class node_class(object):
if nodename.find(INVALID_CHARS[invalid]) :
nodename=nodename.replace(INVALID_CHARS[invalid],invalid)
nodename = self.get_translation(nodename, self.context['lang'])
- where.append((_dirname_field,'like',nodename))
+ where.append((_dirname_field,'=',nodename))
if self.object.ressource_tree:
if obj._parent_name in obj.fields_get(self.cr,self.uid):
@@ -205,14 +207,16 @@ class node_class(object):
ids = obj.search(self.cr, self.uid, where)
res = obj.browse(self.cr, self.uid, ids,self.context)
- for r in res:
+ for r in res:
if len(obj.fields_get(self.cr, self.uid, [_dirname_field])):
r.name = eval('r.'+_dirname_field)
else:
- r.name = name_for+'%d'%r.id
+ r.name = False
+ if not r.name:
+ r.name = name_for + '%d'%r.id
for invalid in INVALID_CHARS:
if r.name.find(invalid) :
- r.name=r.name.replace(invalid,INVALID_CHARS[invalid])
+ r.name = r.name.replace(invalid,INVALID_CHARS[invalid])
result2 = map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name.replace('/','__'), self.object, x, context=self.context, root=x.id), res)
if result2:
if self.object.ressource_tree:
@@ -323,7 +327,7 @@ class document_directory(osv.osv):
where = []
if nodename:
nodename = self.get_translation(nodename, self.context['lang'])
- where.append(('name','like',nodename))
+ where.append(('name','=',nodename))
if object:
where.append(('parent_id','=',object.id))
ids = self.search(cr, uid, where, context)
@@ -718,9 +722,45 @@ class document_configuration_wizard(osv.osv_memory):
'host': fields.char('Server Address', size=64, help="Put here the server address or IP. " \
"Keep localhost if you don't know what to write.", required=True)
}
+
+ def detect_ip_addr(self, cr, uid, context=None):
+ def _detect_ip_addr(self, cr, uid, context=None):
+ from array import array
+ import socket
+ from struct import pack, unpack
+
+ try:
+ import fcntl
+ except ImportError:
+ fcntl = None
+
+ if not fcntl: # not UNIX:
+ host = socket.gethostname()
+ ip_addr = socket.gethostbyname(host)
+ else: # UNIX:
+ # get all interfaces:
+ nbytes = 128 * 32
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ names = array('B', '\0' * nbytes)
+ outbytes = unpack('iL', fcntl.ioctl( s.fileno(), 0x8912, pack('iL', nbytes, names.buffer_info()[0])))[0]
+ namestr = names.tostring()
+ ifaces = [namestr[i:i+32].split('\0', 1)[0] for i in range(0, outbytes, 32)]
+
+ for ifname in [iface for iface in ifaces if iface != 'lo']:
+ ip_addr = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, pack('256s', ifname[:15]))[20:24])
+ break
+ return ip_addr
+
+ try:
+ ip_addr = _detect_ip_addr(self, cr, uid, context)
+ except:
+ ip_addr = 'localhost'
+ return ip_addr
+
_defaults = {
- 'host': lambda *args: 'localhost'
+ 'host': detect_ip_addr,
}
+
def action_cancel(self,cr,uid,ids,conect=None):
return {
'view_type': 'form',
diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py
index b3dec8f2b5e..a59d61e8dd1 100644
--- a/addons/document/ftpserver/abstracted_fs.py
+++ b/addons/document/ftpserver/abstracted_fs.py
@@ -13,6 +13,7 @@ import netsvc
import os
from service import security
from osv import osv
+import stat
def log(message):
logger = netsvc.Logger()
@@ -126,17 +127,20 @@ class abstracted_fs:
for db_name in result:
db, cr = None, None
try:
- db = pooler.get_db_only(db_name)
- cr = db.cursor()
- cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
- if not cr.fetchone():
- continue
-
- cr.execute("select id from ir_module_module where name like 'document%' and state='installed' ")
- res = cr.fetchone()
- if res and len(res):
- self.db_name_list.append(db_name)
- cr.commit()
+ try:
+ db = pooler.get_db_only(db_name)
+ cr = db.cursor()
+ cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
+ if not cr.fetchone():
+ continue
+
+ cr.execute("select id from ir_module_module where name like 'document%' and state='installed' ")
+ res = cr.fetchone()
+ if res and len(res):
+ self.db_name_list.append(db_name)
+ cr.commit()
+ except Exception, e:
+ log(e)
finally:
if cr is not None:
cr.close()
@@ -794,8 +798,7 @@ class abstracted_fs:
if 'd' in perms:
permdir += 'p'
type = size = perm = modify = create = unique = mode = uid = gid = ""
- for basename in listing:
- file = os.path.join(basedir, basename)
+ for file in listing:
try:
st = self.stat(file)
except OSError:
@@ -805,12 +808,7 @@ class abstracted_fs:
# type + perm
if stat.S_ISDIR(st.st_mode):
if 'type' in facts:
- if basename == '.':
- type = 'type=cdir;'
- elif basename == '..':
- type = 'type=pdir;'
- else:
- type = 'type=dir;'
+ type = 'type=dir;'
if 'perm' in facts:
perm = 'perm=%s;' %permdir
else:
@@ -852,9 +850,9 @@ class abstracted_fs:
# on Windows NTFS filesystems MTF records could be used).
if 'unique' in facts:
unique = "unique=%x%x;" %(st.st_dev, st.st_ino)
- basename=_to_decode(basename)
+ path=_to_decode(file.path)
yield "%s%s%s%s%s%s%s%s%s %s\r\n" %(type, size, perm, modify, create,
- mode, uid, gid, unique, basename)
+ mode, uid, gid, unique, path)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/document/i18n/fr_FR.po b/addons/document/i18n/fr_FR.po
index 0ee8d957355..c88ecf0d8d8 100644
--- a/addons/document/i18n/fr_FR.po
+++ b/addons/document/i18n/fr_FR.po
@@ -6,14 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 5.0.1\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
-"POT-Creation-Date: 2009-05-19 14:22:20+0000\n"
-"PO-Revision-Date: 2009-05-20 10:22:20+0000\n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2009-05-19 14:36+0000\n"
+"PO-Revision-Date: 2009-05-20 14:49+0000\n"
+"Last-Translator: Fabien (Open ERP) <fp@tinyerp.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: \n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Launchpad-Export-Date: 2009-07-07 11:16+0000\n"
+"X-Generator: Launchpad (build Unknown)\n"
#. module: document
#: code:addons/document/document.py:0
@@ -23,8 +24,13 @@ msgstr "Le nom du répertoire ne doit pas contenir de caractères spéciaux!"
#. module: document
#: help:document.directory,ressource_type_id:0
-msgid "Select an object here and Open ERP will create a mapping for each of these objects, using the given domain, when browsing through FTP."
-msgstr "Sélectionnez un objet ici et open ERP créera un répertoire pour chaque occurrence de l'objet en fonction du domaine utilisé lorsque vous parcourrez les fichiers à travers le FTP"
+msgid ""
+"Select an object here and Open ERP will create a mapping for each of these "
+"objects, using the given domain, when browsing through FTP."
+msgstr ""
+"Sélectionnez un objet ici et open ERP créera un répertoire pour chaque "
+"occurrence de l'objet en fonction du domaine utilisé lorsque vous parcourrez "
+"les fichiers à travers le FTP"
#. module: document
#: constraint:ir.actions.act_window:0
@@ -38,8 +44,12 @@ msgstr "Type de Contenu du Répertoire"
#. module: document
#: view:document.configuration.wizard:0
-msgid "This wizard will automatically configure the document management system according to modules installed on your system."
-msgstr "Cet assistant configurera automatiquement la gestion documentaire en fonction des modules installés sur votre système"
+msgid ""
+"This wizard will automatically configure the document management system "
+"according to modules installed on your system."
+msgstr ""
+"Cet assistant configurera automatiquement la gestion documentaire en "
+"fonction des modules installés sur votre système"
#. module: document
#: field:document.directory,file_ids:0
@@ -59,8 +69,12 @@ msgstr "Gestion des Documents"
#. module: document
#: help:document.configuration.wizard,host:0
-msgid "Put here the server address or IP. Keep localhost if you don't know what to write."
-msgstr "Saisissez l'adresse du serveur ou son IP. (Laissez localhost si vous ne savez pas quoi écrire)"
+msgid ""
+"Put here the server address or IP. Keep localhost if you don't know what to "
+"write."
+msgstr ""
+"Saisissez l'adresse du serveur ou son IP. (Laissez localhost si vous ne "
+"savez pas quoi écrire)"
#. module: document
#: view:ir.attachment:0
@@ -171,12 +185,15 @@ msgstr "Le nom du répertoire doit être unique!"
#. module: document
#: help:document.directory,ressource_tree:0
-msgid "Check this if you want to use the same tree structure as the object selected in the system."
+msgid ""
+"Check this if you want to use the same tree structure as the object selected "
+"in the system."
msgstr ""
#. module: document
#: help:document.directory,domain:0
-msgid "Use a domain if you want to apply an automatic filter on visible resources."
+msgid ""
+"Use a domain if you want to apply an automatic filter on visible resources."
msgstr ""
#. module: document
@@ -308,7 +325,9 @@ msgstr "Configurer le Répertoire"
#. module: document
#: model:ir.actions.todo,note:document.config_auto_directory
-msgid "This wizard will configure the URL of the server of the document management system."
+msgid ""
+"This wizard will configure the URL of the server of the document management "
+"system."
msgstr ""
#. module: document
@@ -390,8 +409,13 @@ msgstr "Créateur"
#. module: document
#: help:document.directory,ressource_parent_type_id:0
-msgid "If you put an object here, this directory template will appear bellow all of these objects. Don't put a parent directory if you select a parent model."
-msgstr "Si vous mettez un objet ici, ce répertoire modèle apparaîtra en dessous de tous ces objets. Ne pas mettre de répertoire parent si vous sélectionnez un modèle parent"
+msgid ""
+"If you put an object here, this directory template will appear bellow all of "
+"these objects. Don't put a parent directory if you select a parent model."
+msgstr ""
+"Si vous mettez un objet ici, ce répertoire modèle apparaîtra en dessous de "
+"tous ces objets. Ne pas mettre de répertoire parent si vous sélectionnez un "
+"modèle parent"
#. module: document
#: view:document.directory:0
@@ -415,13 +439,20 @@ msgstr ""
#. module: document
#: constraint:ir.model:0
-msgid "The Object name must start with x_ and not contain any special character !"
-msgstr "Le nom de l'objet doit commencer avec x_ et ne pas contenir de charactères spéciaux !"
+msgid ""
+"The Object name must start with x_ and not contain any special character !"
+msgstr ""
+"Le nom de l'objet doit commencer avec x_ et ne pas contenir de charactères "
+"spéciaux !"
#. module: document
#: help:document.directory.content,include_name:0
-msgid "Check this field if you want that the name of the file start by the record name."
-msgstr "Cochez cette case si vous souhaitez que le nom du fichier commence par le nom de l'enregistrement"
+msgid ""
+"Check this field if you want that the name of the file start by the record "
+"name."
+msgstr ""
+"Cochez cette case si vous souhaitez que le nom du fichier commence par le "
+"nom de l'enregistrement"
#. module: document
#: selection:document.directory,type:0
@@ -456,11 +487,11 @@ msgstr "Parcourir les fichiers via FTP"
#. module: document
#: model:ir.module.module,description:document.module_meta_information
-msgid "This is a complete document management system:\n"
+msgid ""
+"This is a complete document management system:\n"
" * FTP Interface\n"
" * User Authentication\n"
" * Document Indexation\n"
-""
msgstr ""
#. module: document
@@ -493,4 +524,3 @@ msgstr "Configuration Automatique"
#: field:document.directory.content,extension:0
msgid "Document Type"
msgstr "Type de document"
-