forked from expo/troggle
partial fix to make OK on python3.8
This commit is contained in:
parent
0a864c7f87
commit
44d190e91c
@ -274,16 +274,20 @@ class LogbookEntry(TroggleModel):
|
|||||||
return CaveSlug.objects.get(slug = self.cave_slug).cave
|
return CaveSlug.objects.get(slug = self.cave_slug).cave
|
||||||
# parse error in python3.8
|
# parse error in python3.8
|
||||||
# https://stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass
|
# https://stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass
|
||||||
return super(LogbookEntry, self).__getattribute__(item)
|
#https://github.com/django/django/pull/7653
|
||||||
|
#return TroggleModel.__getattribute__(item)
|
||||||
|
#return super(LogbookEntry, self).__getattribute__(item) # works in py3.5, fails in 3.8
|
||||||
|
return TroggleModel.__getattribute__(self,item) # works in py 3.5 AND in 3.8
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "cave" in list(kwargs.keys()):
|
if "cave" in list(kwargs.keys()):
|
||||||
if kwargs["cave"] is not None:
|
if kwargs["cave"] is not None:
|
||||||
kwargs["cave_slug"] = CaveSlug.objects.get(cave=kwargs["cave"], primary=True).slug
|
kwargs["cave_slug"] = CaveSlug.objects.get(cave=kwargs["cave"], primary=True).slug
|
||||||
kwargs.pop("cave")
|
kwargs.pop("cave")
|
||||||
# parse error in python3.8
|
# parse error in python3.8
|
||||||
# https://stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass
|
#return TroggleModel().__init__(self, *args, **kwargs) # parses OK, fails at runtime in 3.8
|
||||||
return super(LogbookEntry, self).__init__(*args, **kwargs)
|
return super(LogbookEntry, self).__init__(*args, **kwargs) # works in py3.5
|
||||||
|
#return TroggleModel.__init__(*args, **kwargs) # fails in py3.5,
|
||||||
|
|
||||||
def isLogbookEntry(self): # Function used in templates
|
def isLogbookEntry(self): # Function used in templates
|
||||||
return True
|
return True
|
||||||
@ -520,10 +524,10 @@ class Cave(TroggleModel):
|
|||||||
|
|
||||||
def writeDataFile(self):
|
def writeDataFile(self):
|
||||||
try:
|
try:
|
||||||
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
|
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "wb")
|
||||||
except:
|
except:
|
||||||
subprocess.call(settings.FIX_PERMISSIONS)
|
subprocess.call(settings.FIX_PERMISSIONS)
|
||||||
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
|
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "wb")
|
||||||
t = loader.get_template('dataformat/cave.xml')
|
t = loader.get_template('dataformat/cave.xml')
|
||||||
c = Context({'cave': self})
|
c = Context({'cave': self})
|
||||||
u = t.render(c)
|
u = t.render(c)
|
||||||
@ -733,12 +737,14 @@ class CaveDescription(TroggleModel):
|
|||||||
def save(self):
|
def save(self):
|
||||||
"""
|
"""
|
||||||
Overridden save method which stores wikilinks in text as links in database.
|
Overridden save method which stores wikilinks in text as links in database.
|
||||||
"""
|
"""
|
||||||
super(CaveDescription, self).save()
|
TroggleModel.save()
|
||||||
|
#super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||||
qm_list=get_related_by_wikilinks(self.description)
|
qm_list=get_related_by_wikilinks(self.description)
|
||||||
for qm in qm_list:
|
for qm in qm_list:
|
||||||
self.linked_qms.add(qm)
|
self.linked_qms.add(qm)
|
||||||
super(CaveDescription, self).save()
|
TroggleModel.save()
|
||||||
|
#super(CaveDescription, self).save() # fails in python 3.8, OK in python 3.5
|
||||||
|
|
||||||
class NewSubCave(TroggleModel):
|
class NewSubCave(TroggleModel):
|
||||||
name = models.CharField(max_length=200, unique = True)
|
name = models.CharField(max_length=200, unique = True)
|
||||||
|
Loading…
Reference in New Issue
Block a user