def load(self, id):
        """\
		load(id)

		Loads a thing from the database.
		"""
        SQLBase.load(self, id)

        # Load the categories now
        self.categories = self.get_categories()
	def load(self, id):
		"""\
		load(id)

		Loads a thing from the database.
		"""
		SQLBase.load(self, id)

		# Load the categories now
		self.categories = self.get_categories()
	def remove(self):
		trans = dbconn.begin()
		try:
			# Move the other orders down
			t = self.table
			update(t, (t.c.slot >= bindparam('s')) & (t.c.bid==bindparam('b')), {'slot': t.c.slot-1}).execute(s=self.slot, b=self.bid)

			self.board.save()
			SQLBase.remove(self)

			trans.commit()
		except Exception, e:
			trans.rollback()
			raise
	def from_packet(cls, user, packet):
		self = SQLBase.from_packet(cls, user, packet)

		self.bid = packet.id
		del self.id

		return self
	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
예제 #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)
	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)
예제 #9
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)
예제 #10
0
	def protect(self, user):
		o = SQLBase.protect(self, user)
		if hasattr(self, "owner") and self.owner != user.id:
			print self.owner
			def empty():
				return 0
			o.orders = empty
			
			def empty():
				return []
			o.ordertypes = empty
		return o
예제 #11
0
	def __init__(self, bid=None, slot=None, id=None):
		if bid != None and slot != None:
			id = self.realid(bid, slot)

		SQLBase.__init__(self, id)