Exemple #1
0
 def __init__(self, otherClass=None, **kw):
     kw['otherClass'] = otherClass
     self.kw = kw
     if self.kw.has_key('joinMethodName'):
         self._joinMethodName = popKey(self.kw, 'joinMethodName')
     else:
         self._joinMethodName = None
Exemple #2
0
    def get(self, *args, **kw):
        if not self.unique:
            raise AttributeError, (
                "'%s' object has no attribute 'get' (index is not unique)" % self.name)
        connection = col.popKey(kw, 'connection', None)
        if args and kw:
            raise TypeError, "You cannot mix named and unnamed arguments"
        columns = [d['column'] for d in self.descriptions
            if d.has_key('column')]
        if kw and len(kw) != len(columns) or args and len(args) != len(columns):
            raise TypeError, ("get() takes exactly %d argument and an optional "
                "named argument 'connection' (%d given)" % (
                len(columns), len(args)+len(kw)))
        if args:
            kw = {}
            for i in range(len(args)):
                if columns[i].foreignName is not None:
                    kw[columns[i].foreignName] = args[i]
                else:
                    kw[columns[i].name] = args[i]
	return self.soClass.selectBy(connection=connection, **kw).getOne()
Exemple #3
0
 def get(self, *args, **kw):
     if not self.unique:
         raise AttributeError, (
             "'%s' object has no attribute 'get' (index is not unique)" % self.name)
     connection = col.popKey(kw, 'connection', None)
     if args and kw:
         raise TypeError, "You cannot mix named and unnamed arguments"
     columns = [d['column'] for d in self.descriptions
         if d.has_key('column')]
     if kw:
         args = []
         for i in xrange(len(columns)):
             args.append(kw[columns[i].name])
             del kw[columns[i].name]
     if kw or len(args) != len(columns):
         raise TypeError, ("get() takes exactly %d argument and an optional "
             "named argument 'connection' (%d given)" % (
             len(columns), len(args)+len(kw)))
     cols = [c.name for c in columns]
     dbcols = [c.dbName for c in columns]
     return self.soClass._SO_fetchAlternateID(cols, dbcols, args,
         connection=connection, idxName=self.name)
Exemple #4
0
 def __init__(self, **kw):
     self.makeDefault = popKey(kw, 'makeDefault', False)
     SOMultipleJoin.__init__(self, **kw)