def __init__(self, model=None): self.model = model self.id = genID() if model: for fm in model.fieldModels: self.fields.append(Field(fm)) self.new = True
def copy(self): new = FieldModel() for p in class_mapper(FieldModel).iterate_properties: setattr(new, p.key, getattr(self, p.key)) new.id = genID() new.model = None return new
def updateMediaCount(deck, file, count=1): mdir = deck.mediaDir() if deck.s.scalar( "select 1 from media where filename = :file", file=file): deck.s.statement( "update media set size = size + :c, created = :t where filename = :file", file=file, c=count, t=time.time()) elif count > 0: try: sum = str( checksum(open(os.path.join(mdir, file), "rb").read())) except: sum = "" deck.s.statement(""" insert into media (id, filename, size, created, originalPath, description) values (:id, :file, :c, :mod, :sum, '')""", id=genID(), file=file, c=count, mod=time.time(), sum=sum)
def updateMediaCount(deck, file, count=1): mdir = deck.mediaDir() if deck.s.scalar( "select 1 from media where filename = :file", file=file): deck.s.statement( "update media set size = size + :c, created = :t where filename = :file", file=file, c=count, t=time.time()) elif count > 0: try: sum = unicode( checksum(open(os.path.join(mdir, file), "rb").read())) except: sum = u"" deck.s.statement(""" insert into media (id, filename, size, created, originalPath, description) values (:id, :file, :c, :mod, :sum, '')""", id=genID(), file=file, c=count, mod=time.time(), sum=sum)
def __init__(self, fact=None, cardModel=None, created=None): self.tags = u"" self.id = genID() # new cards start as new & due self.type = 2 self.relativeDelay = self.type self.timerStarted = False self.timerStopped = False self.modified = time.time() if created: self.created = created self.due = created else: self.due = self.modified self.combinedDue = self.due if fact: self.fact = fact if cardModel: self.cardModel = cardModel # for non-orm use self.cardModelId = cardModel.id self.ordinal = cardModel.ordinal
def __init__(self, fact=None, cardModel=None, created=None): self.tags = "" self.id = genID() # new cards start as new & due self.type = 2 self.relativeDelay = self.type self.timerStarted = False self.timerStopped = False self.modified = time.time() if created: self.created = created self.due = created else: self.due = self.modified self.combinedDue = self.due if fact: self.fact = fact if cardModel: self.cardModel = cardModel # for non-orm use self.cardModelId = cardModel.id self.ordinal = cardModel.ordinal
def __init__(self, fieldModel=None): if fieldModel: self.fieldModel = fieldModel self.ordinal = fieldModel.ordinal self.value = "" self.id = genID()
def __init__(self, fieldModel=None): if fieldModel: self.fieldModel = fieldModel self.ordinal = fieldModel.ordinal self.value = u"" self.id = genID()
def __init__(self, name=u"", required=True, unique=True): self.name = name self.required = required self.unique = unique self.id = genID()
def __init__(self, name=u""): self.name = name self.id = genID()
def __init__(self, name=u"", qformat=u"q", aformat=u"a", active=True): self.name = name self.qformat = qformat self.aformat = aformat self.active = active self.id = genID()