Exemplo n.º 1
0
    def setUp(self):
      self.pw               = PonyWhoosh()
      self.pw.indexes_path  = tempfile.mkdtemp()
      self.pw.debug         = False
      self.db               = Database()

      @self.pw.register_model('name', 'age', stored=True, sortable=True)
      class User(self.db.Entity):
        id         = PrimaryKey(int, auto=True)
        name       = Required(str)
        age        = Optional(int)
        attributes = Set('Attribute')

      @self.pw.register_model('weight', 'sport', 'name', stored=True, sortable=True)
      class Attribute(self.db.Entity):
        id      = PrimaryKey(int, auto=True)
        name    = Optional(str)
        user    = Optional("User")
        weight  = Required(str)
        sport   = Optional(str)

      self.db.bind('sqlite', ':memory:', create_db=True)
      self.db.generate_mapping(create_tables=True)
      self.User       = User
      self.Attribute  = Attribute
Exemplo n.º 2
0
                                  , DATABASE_SEARCH_INDEXES_PATH
                                  , GITHUB_USER
                                  , INDEX_REPOSITORY_BRANCH
                                  , INDEX_REPOSITORY_NAME
                                  , INDEX_REPOSITORY_PATH
                                  , INDEX_REPOSITORY_URL
                                  , PACKAGE_SOURCES_PATH
                                  , REPO
                                  , PKG_SUFFIX
                                  , LIB_SUFFIX
                                  )

# ----------------------------------------------------------------------------

# -- Search index
pw = PonyWhoosh()

pw.indexes_path          = DATABASE_SEARCH_INDEXES_PATH
pw.search_string_min_len = 1
pw.writer_timeout        = 3

db = Database()


# Library is the general object to store the information about
# an Agda library. Each library is associated with its different
# versions. These versions are instance of the object LibraryVersion.

@pw.register_model('name', 'description', 'url')
class Library(db.Entity):
    name         = PrimaryKey(str)