2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 15:21:52 +00:00

partial fix to make OK on python3.8

This commit is contained in:
Philip Sargent 2020-05-25 01:49:02 +01:00
parent 0a864c7f87
commit 44d190e91c

View File

@ -274,7 +274,10 @@ class LogbookEntry(TroggleModel):
return CaveSlug.objects.get(slug = self.cave_slug).cave
# parse error in python3.8
# 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):
if "cave" in list(kwargs.keys()):
@ -282,8 +285,9 @@ class LogbookEntry(TroggleModel):
kwargs["cave_slug"] = CaveSlug.objects.get(cave=kwargs["cave"], primary=True).slug
kwargs.pop("cave")
# parse error in python3.8
# https://stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass
return super(LogbookEntry, self).__init__(*args, **kwargs)
#return TroggleModel().__init__(self, *args, **kwargs) # parses OK, fails at runtime in 3.8
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
return True
@ -520,10 +524,10 @@ class Cave(TroggleModel):
def writeDataFile(self):
try:
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "wb")
except:
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')
c = Context({'cave': self})
u = t.render(c)
@ -734,11 +738,13 @@ class CaveDescription(TroggleModel):
"""
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)
for qm in qm_list:
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):
name = models.CharField(max_length=200, unique = True)