Exemplo n.º 1
0
 def create(self):
     baselog.get_logger('peewee').setLevel(logging.DEBUG)
     logger.debug("Creating database [" + str(self.title) + "] on [" +
                  str(self.host) + "]")
     self.db = self.construct_database_handle()
     self.get_model_factory().build(self)
     return self._models
Exemplo n.º 2
0
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import baselog

logger = baselog.get_logger(__name__)

# Shared broadcast ids
BROADCAST_SHUTDOWN = "broadcast_shutdown_key"

"""Allow arbitrary callbacks between parts of an application
 Simply register a 'listener' (a callback function) with any
 id. When something else decides to 'notify' for an id, all
 corresponding listener functions are called"""
_listener_map = {}


def add_listener(broadcast_id, broadcast_listener):
    """Start listening on a particular id"""
    if not callable(broadcast_listener):
        raise Exception("broadcast_listener must be callable")