diff --git a/admidio.py b/admidio.py index 6f0b9e5..bc76fa5 100644 --- a/admidio.py +++ b/admidio.py @@ -1,8 +1,9 @@ import MySQLdb -import admidio_python_api.member as member -import admidio_python_api.group as group -import admidio_python_api.event as event -from admidio_python_api.exceptions import MemberNotFoundException + +from .member import Member as member +from .group import Group as group +from .event import Event as event +from .exceptions import MemberNotFoundException from datetime import datetime from dateutil.relativedelta import relativedelta @@ -40,6 +41,17 @@ class Admidio: def __del__(self): self.db.close() + def refresh(self): + """Refresh all users, groups and events that are stored""" + self.ready = False + self.members = dict() + self.groups = dict() + self.events = dict() + self.initMembers() + self.initGroups() + self.initEvents() + self.ready = True + def initMembers(self): """Initialises all members in the Admidio installation""" @@ -48,7 +60,7 @@ class Admidio: self.cursor.execute(sql) for row in self.cursor.fetchall(): - self.members[row[0]] = member.Member( + self.members[row[0]] = member( self.db, row[0], row[1], row[2], self.userfields, self) @@ -62,7 +74,7 @@ class Admidio: self.cursor.execute(sql) for row in self.cursor.fetchall(): - self.groups[row[0]] = group.Group(row[0], row[1], self) + self.groups[row[0]] = group(row[0], row[1], self) def initEvents(self): """Initialises all comming events and passed events <3 months""" @@ -79,7 +91,7 @@ class Admidio: self.cursor.execute(sql) for row in self.cursor.fetchall(): - self.events[row[0]] = event.Event( + self.events[row[0]] = event( row[0], row[8], row[4], row[2], row[3], row[5], row[6], row[7], self)