def save(self, forceinsert=False):
		"""\
		save()

		Saves a thing to the database.
		"""
		SQLTypedBase.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.component==self.id) & (t.c.category==cid)).execute()
			
			if (not cid in current) and (cid in self.categories):
				# Add the category
				results = insert(t).execute(component=self.id, category=cid)

		# Save the Properties now
		t = self.table_property
		current = self.get_properties()
		for cid in current+self.properties.keys():
			if (cid in current) and (not cid in self.properties.keys()):
				# Remove the category
				results = delete(t, (t.c.component==self.id) & (t.c.property==cid)).execute()
			
			elif (not cid in current) and (cid in self.properties.keys()):
				# Add the category
				results = insert(t).execute(component=self.id, property=cid, value=self.properties[cid])

			else:
				# Update the property
				results = update(t, (t.c.component==self.id) & (t.c.property==cid)).execute(component=self.id, property=cid, value=self.properties[cid])
Ejemplo n.º 2
0
	def save(self):
		trans = dbconn.begin()
		try:
			# Update the modtime...
			self.object.save()

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

			SQLTypedBase.save(self)

			trans.commit()
		except Exception, e:
			trans.rollback()
			raise
Ejemplo n.º 3
0
    def save(self):
        trans = dbconn.begin()
        try:
            # Update the modtime...
            self.object.save()

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

            SQLTypedBase.save(self)

            trans.commit()
        except Exception, e:
            trans.rollback()
            raise
Ejemplo n.º 4
0
    def save(self, forceinsert=False):
        """\
		save()

		Saves a thing to the database.
		"""
        SQLTypedBase.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.component == self.id) &
                                 (t.c.category == cid)).execute()

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

        # Save the Properties now
        t = self.table_property
        current = self.get_properties()
        for cid in current + self.properties.keys():
            if (cid in current) and (not cid in self.properties.keys()):
                # Remove the category
                results = delete(t, (t.c.component == self.id) &
                                 (t.c.property == cid)).execute()

            elif (not cid in current) and (cid in self.properties.keys()):
                # Add the category
                results = insert(t).execute(component=self.id,
                                            property=cid,
                                            value=self.properties[cid])

            else:
                # Update the property
                results = update(t, (t.c.component == self.id) &
                                 (t.c.property == cid)).execute(
                                     component=self.id,
                                     property=cid,
                                     value=self.properties[cid])