def save(self):
		trans = dbconn.begin()
		try:
			# Update the modtime...
			self.board.save()

			if not hasattr(self, 'id'):
				id = self.realid(self.bid, self.slot)
				if id != -1:
					self.id = id

			SQLBase.save(self)

			trans.commit()
		except Exception, e:
			trans.rollback()
			raise
예제 #2
0
    def save(self):
        trans = dbconn.begin()
        try:
            # Update the modtime...
            self.board.save()

            if not hasattr(self, 'id'):
                id = self.realid(self.bid, self.slot)
                if id != -1:
                    self.id = id

            SQLBase.save(self)

            trans.commit()
        except Exception, e:
            trans.rollback()
            raise
예제 #3
0
    def save(self, forceinsert=False):
        """\
		save()

		Saves a thing to the database.
		"""
        SQLBase.save(self, forceinsert)

        # Save the categories now
        t = self.table_category
        current = self.get_categories()
        for cid in current + self.categories:
            if (cid in current) and (not cid in self.categories):
                # Remove the category
                results = delete(t, (t.c.design == self.id) &
                                 (t.c.category == cid)).execute()

            if (not cid in current) and (cid in self.categories):
                # Add the category
                results = insert(t).execute(design=self.id, category=cid)

        # Save the components now
        t = self.table_component
        current = self.get_components()

        ct = {}
        for cid, amount in current:
            ct[cid] = [amount, None]
        for cid, amount in self.components:
            if ct.has_key(cid):
                ct[cid][1] = amount
            else:
                ct[cid] = [None, amount]

        for cid, values in ct.items():
            start, end = values

            if start != end:
                if start != None:
                    results = delete(t, (t.c.design == self.id) &
                                     (t.c.component == cid)).execute()
                if end != None and end > 0:
                    results = insert(t).execute(design=self.id,
                                                component=cid,
                                                amount=end)
	def save(self, forceinsert=False):
		"""\
		save()

		Saves a thing to the database.
		"""
		SQLBase.save(self, forceinsert)

		# Save the categories now
		t = self.table_category
		current = self.get_categories()
		for cid in current+self.categories:
			if (cid in current) and (not cid in self.categories):
				# Remove the category
				results = delete(t, (t.c.property==self.id) & (t.c.category==cid)).execute()
			
			if (not cid in current) and (cid in self.categories):
				# Add the category
				results = insert(t).execute(property=self.id, category=cid)
    def save(self, forceinsert=False):
        """\
		save()

		Saves a thing to the database.
		"""
        SQLBase.save(self, forceinsert)

        # Save the categories now
        t = self.table_category
        current = self.get_categories()
        for cid in current + self.categories:
            if (cid in current) and (not cid in self.categories):
                # Remove the category
                results = delete(t, (t.c.property == self.id) &
                                 (t.c.category == cid)).execute()

            if (not cid in current) and (cid in self.categories):
                # Add the category
                results = insert(t).execute(property=self.id, category=cid)
예제 #6
0
    def save(self, forceinsert=False):
        """\
		save()

		Saves a thing to the database.
		"""
        SQLBase.save(self, forceinsert)

        # Save the categories now
        t = self.table_category
        current = self.get_categories()
        for cid in current + self.categories:
            if (cid in current) and (not cid in self.categories):
                # Remove the category
                results = delete(t, (t.c.design == self.id) & (t.c.category == cid)).execute()

            if (not cid in current) and (cid in self.categories):
                # Add the category
                results = insert(t).execute(design=self.id, category=cid)

                # Save the components now
        t = self.table_component
        current = self.get_components()

        ct = {}
        for cid, amount in current:
            ct[cid] = [amount, None]
        for cid, amount in self.components:
            if ct.has_key(cid):
                ct[cid][1] = amount
            else:
                ct[cid] = [None, amount]

        for cid, values in ct.items():
            start, end = values

            if start != end:
                if start != None:
                    results = delete(t, (t.c.design == self.id) & (t.c.component == cid)).execute()
                if end != None and end > 0:
                    results = insert(t).execute(design=self.id, component=cid, amount=end)