Commit d3c93501 authored by Bartek Górny's avatar Bartek Górny

fixed a number of bugs

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12401 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bbcd7d69
...@@ -510,15 +510,17 @@ class Document(XMLObject): ...@@ -510,15 +510,17 @@ class Document(XMLObject):
for r in res: for r in res:
if lista.get(r) is None: if lista.get(r) is None:
lista[r] = True # we use dict keys to ensure uniqueness lista[r] = True # we use dict keys to ensure uniqueness
if level != depth: if level != depth:
getRelatedList(r, level) getRelatedList(r, level)
getRelatedList(self) getRelatedList(self)
lista_latest = {} lista_latest = {}
for o in lista.keys(): for o in lista.keys():
lista_latest[o.getLatestVersionValue()] = True # get latest versions avoiding duplicates again lista_latest[o.getLatestVersionValue()] = True # get latest versions avoiding duplicates again
if lista_latest.has_key(self): lista_latest.pop(self) # remove this document if lista_latest.has_key(self):
if lista_latest.has_key(self.getLatestVersionValue()): lista_latest.pop(self()) # remove this document lista_latest.pop(self) # remove this document
if lista_latest.has_key(self.getLatestVersionValue()):
lista_latest.pop(self()) # remove this document
return lista_latest.keys() return lista_latest.keys()
...@@ -546,6 +548,8 @@ class Document(XMLObject): ...@@ -546,6 +548,8 @@ class Document(XMLObject):
in original language or in the user language if the version is in original language or in the user language if the version is
the same. the same.
""" """
if not self.getReference():
return self
catalog = getToolByName(self, 'portal_catalog', None) catalog = getToolByName(self, 'portal_catalog', None)
kw = dict(reference=self.getReference(), sort_on=(('version','descending'),('revision','descending'),)) kw = dict(reference=self.getReference(), sort_on=(('version','descending'),('revision','descending'),))
if language is not None: kw['language'] = language if language is not None: kw['language'] = language
...@@ -556,7 +560,7 @@ class Document(XMLObject): ...@@ -556,7 +560,7 @@ class Document(XMLObject):
# if language was given return it # if language was given return it
if language is not None: if language is not None:
return res[0] return res[0].getObject()
else: else:
first = res[0] first = res[0]
in_original = None in_original = None
...@@ -567,12 +571,12 @@ class Document(XMLObject): ...@@ -567,12 +571,12 @@ class Document(XMLObject):
if ob.getVersion() != first.getVersion(): if ob.getVersion() != first.getVersion():
# we are out of the latest version - return in_original or first # we are out of the latest version - return in_original or first
if in_original is not None: if in_original is not None:
return in_original return in_original.getObject()
else: else:
return first # this shouldn't happen in real life return first.getObject() # this shouldn't happen in real life
if ob.getLanguage() == user_language: if ob.getLanguage() == user_language:
# we found it in the user language # we found it in the user language
return ob return ob.getObject()
# this is the only doc in this version # this is the only doc in this version
return self return self
...@@ -794,7 +798,7 @@ class Document(XMLObject): ...@@ -794,7 +798,7 @@ class Document(XMLObject):
# Start with everything until content - build a dictionnary according to the order # Start with everything until content - build a dictionnary according to the order
kw = {} kw = {}
first_list = order_list[0:content_index-1] first_list = order_list[:content_index]
first_list.reverse() first_list.reverse()
for order_id in first_list: for order_id in first_list:
if order_id not in VALID_ORDER_KEY_LIST: if order_id not in VALID_ORDER_KEY_LIST:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment