def post(self): doc = minidom.parse(self.request.body_file) ModelName = doc.documentElement.tagName if ModelName == 'Medlog': try: Id = nextval('Medlogid') except: Id = None try: Nr = doc.getElementsByTagName("Nr")[0].childNodes[0].data except: Nr = None root = db.Key.from_path('Persons', 'root', 'Person', '%s' % (Nr)) rec = Medlog.get_or_insert('%s' % (Id), parent=root) for attr_name, value in Medlog.__dict__.iteritems(): if isinstance(value, db.Property): attr_type = value.__class__.__name__ if not attr_type in ['_ReverseReferenceProperty']: val = self.attr_val(doc, attr_name, attr_type) logging.info('%s=%s' % (attr_name, val)) try: setattr(rec, attr_name, val) except: setattr(rec, attr_name, None) logging.info('==>%s<==>%s<==' % (attr_name, attr_type)) rec.put() deleteMemcache('Medlog') self.response.out.write('Status: 404')
def post(self): perkeys = self.request.get('perkeys') keys = [db.Key(k) for k in perkeys.split()] person_list = db.get(keys) for per in person_list: per.setNameTags() per.put() deleteMemcache('Medlog')
def delete(self): path = self.request.environ['PATH_INFO'] mo = re.match("/sync/Medlem/([0-9]+)", path) if mo: if mo.groups()[0]: try: Nr = mo.groups()[0] logging.info('DELETE Nr=%s' % (Nr)) k = db.Key.from_path('Persons', 'root', 'Person', Nr) m = Person.get(k) m.delete() deleteMemcache('Person') except: pass self.response.out.write('Status: 403')
def post(self): jData = '{ ' Nr = self.request.get('Nr') if Nr == '*': Nr = nextval('Personid') #Test for Valid dato bAkt_dato = False Akt_dato = self.request.get('Akt_dato') if Akt_dato: try: Testdato = datetime.strptime(Akt_dato, "%Y-%m-%d") bAkt_dato = True except: bAkt_dato = False if bAkt_dato: Id = nextval('tblMedlemlog') k = db.Key.from_path('Persons', 'root', 'Person', '%s' % (Nr)) p = Medlog.get_or_insert('%s' % (Id), parent=k) p.Id = Id p.Source = 'Medlog' p.Source_id = Id p.Nr = int(Nr) p.Logdato = datetime.now() p.Akt_id = int(self.request.get('Akt_id')) Akt_dato = self.request.get('Akt_dato') logging.info('Akt_dato: %s' % (Akt_dato)) p.Akt_dato = datetime.strptime(Akt_dato, "%Y-%m-%d").date() p.put() jData += '"bMedlemlog":"true"' jData += ',"MedlemlogTablePos":"%s"' % ( self.request.get('MedlemlogTablePos')) jData += ',"MedlemlogData":["%s","%s","%s","%s","%s","%s","%s"]' % ( p.Nr, p.Source, p.Source_id, p.Logdato, p.Akt_id, p.Akt_dato, p.Akt_id) deleteMemcache('Medlog') Akt_id = self.request.get('Akt_id') if Akt_id == '10': Kontingent_id = nextval('Kontingentid') t = db.Key.from_path('Persons', 'root', 'Person', '%s' % (Nr)) q = Kontingent.get_or_insert('%s' % (Kontingent_id), parent=t) q.Id = int(Kontingent_id) q.Nr = int(Nr) dtFradato = datetime.strptime(Akt_dato, "%Y-%m-%d") q.Fradato = date(dtFradato.year, dtFradato.month, dtFradato.day) q.beregnKontingent() q.put() Navn = self.request.get('Navn') jData += ',"bKontingent":"true"' jData += ',"KontingentTablePos":"%s"' % ( self.request.get('KontingentTablePos')) jData += ',"KontingentData":["%s","%s","%s","%s","%s","%s"]' % ( q.Nr, Navn, q.Fradato, q.Advisbelob, q.Tildato, q.Id) deleteMemcache('Kontingent') else: jData += ',"bKontingent":"false"' else: jData += '"bMedlemlog":"false"' root = db.Key.from_path('Persons', 'root') m = Person.get_or_insert('%s' % (Nr), parent=root) try: m.Navn = self.request.get('Navn') m.Kaldenavn = self.request.get('Kaldenavn') m.Adresse = self.request.get('Adresse') m.Postnr = self.request.get('Postnr') m.Bynavn = self.request.get('Bynavn') m.Telefon = self.request.get('Telefon') m.Email = self.request.get('Email') m.Kon = self.request.get('Kon') dt = datetime.strptime(self.request.get('FodtDato'), "%Y-%m-%d") m.FodtDato = dt.date() logging.info('%s=%s' % ('FodtDato', getattr(m, 'FodtDato'))) m.Bank = self.request.get('Bank') m.setNameTags() m.put() jData += ',"PersonTablePos":"%s"' % ( self.request.get('PersonTablePos')) jData += ',"PersonTableData": ["%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"]' % ( m.Nr, m.Navn, m.Kaldenavn, m.Adresse, m.Postnr, m.Bynavn, m.Email, m.Telefon, m.Kon, m.FodtDato, m.Bank, m.MedlemtilDato, m.MedlemAabenBetalingsdato) jData += ' }' deleteMemcache('Person') logging.info( 'UpdatemedlemHandler OK Navn: %s, Kaldenavn: %s' % (self.request.get('Navn'), self.request.get('Kaldenavn'))) logging.info('%s' % (jData)) self.response.headers["Content-Type"] = "application/json" self.response.out.write(jData) except: logging.info( 'UpdatemedlemHandler ERROR Navn: %s, Kaldenavn: %s' % (self.request.get('Navn'), self.request.get('Kaldenavn'))) self.response.out.write('ERROR from Server')
def post(self): doc = minidom.parse(self.request.body_file) try: Nr = doc.getElementsByTagName("Nr")[0].childNodes[0].data except: Nr = None root = db.Key.from_path('Persons', 'root') person = Person.get_or_insert('%s' % (Nr), parent=root) for n in [ 'Navn', 'Kaldenavn', 'Adresse', 'Postnr', 'Bynavn', 'Email', 'Telefon', 'Kon', 'Bank' ]: val = None bval = True try: val = doc.getElementsByTagName(n)[0].childNodes[0].data except: bval = False if bval: try: setattr(person, n, val) logging.info('%s=%s' % (n, getattr(person, n))) except: setattr(person, n, None) FodtDato = None bFodtDato = True try: FodtDato = doc.getElementsByTagName( "FodtDato")[0].childNodes[0].data except: bFodtDato = False if bFodtDato: try: dt = datetime.strptime(FodtDato, "%Y-%m-%d") person.FodtDato = dt.date() logging.info('%s=%s' % ('FodtDato', getattr(person, 'FodtDato'))) except: person.FodtDato = None person.setNameTags() person.put() deleteMemcache('Person') logging.info( 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ) logging.info( '%s - %s - %s - %s - %s - %s - %s - %s - %s - %s - %s' % (person.Nr, person.Navn, person.Kaldenavn, person.Adresse, person.Postnr, person.Bynavn, person.Email, person.Telefon, person.Kon, person.FodtDato, person.Bank)) logging.info( 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ) self.response.out.write('Status: 404')