Next / Previous / Contents / TCC Help System / NM Tech homepage

7.22. UserDatabase.__init__(): Constructor

The first argument to the gdbm.open() method is the name of the database file. The second argument is a mode string. We use 'c' to open the file read/write, and create it if necessary. The 's' flag instructs gdbm to synchronize transactions to the disk right away.

reader.cgi
# - - -   U s e r D a t a b a s e . _ _ i n i t _ _

    def __init__ ( self ):
        '''Constructor for UserDatabase.
        '''
        self.__db  =  gdbm.open ( DB_NAME, 'cs' )