Example #1
0
    def __init__(self,
                 child_class,
                 child_key=None,
                 foreign_key=None,
                 column=None,
                 title=None,
                 has_default=None,
                 cache=True):
        """
        @param cache: Indicates whether the relationship object shall
           keep a copy of the child object in the dbobj for faster access.
        """
        if foreign_key is not None and column is not None:
            raise Exception("You can't specify both a foreign_key (based"+\
                            " on attribute names) and an SQL column for "+\
                            " a many2one relationship")

        datatype.__init__(self, column, title, (), has_default)

        if foreign_key is None:
            pk = keys.primary_key(child_class)
            self.python_class = pk.attribute().python_class
            self.sql_literal_class = pk.attribute().sql_literal_class

        self.child_class = child_class

        if child_key is None:
            self.child_key = child_class.__primary_key__
        else:
            self.child_key = child_key

        self.foreign_key = foreign_key

        self.cache = cache
Example #2
0
    def __init__(self,
                 child_class,
                 child_key=None,
                 foreign_key=None,
                 title=None,
                 has_default=None):
        """
        @param child_class: The dbclass, this property's owner has a
          relationship to
        @param child_key: A string or a tuple of strings indicating those
           properties of the child_class that are used in the foreign key. This
           defaults to the child's primary key. The child_key must match the
           foreign_key in the number of its members and the attribute's
           datatypes.
        @param foreign_key: The foreign key. Simmlar to a dbclass' primary key
           this may be a simple string, indication the attribute that manages
           the foreign key column or a tuple of strings indicating columns
           that form the foreign key together. If the foreign key parameter is
           None __init_dbclass__() will try to guess the foreign key name as
           'child's table'_'primary key column'.

        """
        datatype.__init__(self,
                          column=None,
                          title=title,
                          validators=(),
                          has_default=has_default)

        self.child_class = child_class
        self.child_key = child_key
        self.foreign_key = foreign_key
Example #3
0
    def __init__(
        self, child_class, child_key=None, foreign_key=None, column=None, title=None, has_default=None, cache=True
    ):
        """
        @param cache: Indicates whether the relationship object shall
           keep a copy of the child object in the dbobj for faster access.
        """
        if foreign_key is not None and column is not None:
            raise Exception(
                "You can't specify both a foreign_key (based"
                + " on attribute names) and an SQL column for "
                + " a many2one relationship"
            )

        datatype.__init__(self, column, title, (), has_default)

        if foreign_key is None:
            pk = keys.primary_key(child_class)
            self.python_class = pk.attribute().python_class
            self.sql_literal_class = pk.attribute().sql_literal_class

        self.child_class = child_class

        if child_key is None:
            self.child_key = child_class.__primary_key__
        else:
            self.child_key = child_key

        self.foreign_key = foreign_key

        self.cache = cache
Example #4
0
 def __init__(self, pickle_protocol=HIGHEST_PROTOCOL,
              column=None, title=None,
              validators=(), has_default=False):
     """
     @param pickle_protocol: Version number of the protocol being used by
        the pickle functions. See U{http://localhost/Documentation/Python/Main/lib/module-pickle.html} for details. 
     """
     self.pickle_protocol = pickle_protocol
     datatype.__init__(self, column, title, validators, 
                      has_default)
Example #5
0
 def __init__(self,
              pickle_protocol=HIGHEST_PROTOCOL,
              column=None,
              title=None,
              validators=(),
              has_default=False):
     """
     @param pickle_protocol: Version number of the protocol being used by
        the pickle functions. See U{http://localhost/Documentation/Python/Main/lib/module-pickle.html} for details. 
     """
     self.pickle_protocol = pickle_protocol
     datatype.__init__(self, column, title, validators, has_default)
Example #6
0
    def __init__(self, child_class, child_key=None, foreign_key=None, title=None, has_default=None):
        """
        @param child_class: The dbclass, this property's owner has a
          relationship to
        @param child_key: A string or a tuple of strings indicating those
           properties of the child_class that are used in the foreign key. This
           defaults to the child's primary key. The child_key must match the
           foreign_key in the number of its members and the attribute's
           datatypes.
        @param foreign_key: The foreign key. Simmlar to a dbclass' primary key
           this may be a simple string, indication the attribute that manages
           the foreign key column or a tuple of strings indicating columns
           that form the foreign key together. If the foreign key parameter is
           None __init_dbclass__() will try to guess the foreign key name as
           'child's table'_'primary key column'.

        """
        datatype.__init__(self, column=None, title=title, validators=(), has_default=has_default)

        self.child_class = child_class
        self.child_key = child_key
        self.foreign_key = foreign_key