text:
Q: Class in class in class in python, how to share information I am trying to create a class for a database using peewee in python. This results in nested classes due to peewee's use of a class named meta in the models. My question is, how do I define the database (=db) within the class Meta? Is there perhaps a better way?
import peewee as pe

    class DataBase():
        class SensorType(pe.Model):
            name = pe.CharField(max_length=255, unique=True)

            class Meta:
                database = db

    def ___init___(self,filename='sensors.db'):
        db = pe.SqliteDatabase(filename)
        db.connect()
        db.create_tables([self.SensorType],safe=True)

    def add_sensor(self,typeName):
        type, created = self.SensorType.get_or_create(name=typeName)
        return type, created

    def get_sensors(self):
        return self.SensorType.select().order_by(self.SensorType.name)

if __name__ == '__main__':

    myDb = DataBase()
    myDb.add_sensor('Test')

    for type in myDb.get_sensors():
        print(type.name)

I found that defining the classes within the __init__ function of my main class works. But it is probably not the preferred approach.
import peewee as pe

class DataBase():
    def __init__(self,filename='sensors.db'):
       db = pe.SqliteDatabase(filename)
       db.connect()

        class SensorType(pe.Model):
           typename = pe.CharField(max_length=255, unique=True)
           class Meta:
              database = db

       self.SensorType = SensorType
       db.create_tables([self.SensorType],safe=True)

    def add_sensor_type(self,typeName):
       type, created = self.SensorType.get_or_create(typename=typeName)
       return type, created

    def get_sensor_types(self):
       return self.SensorType.select()

if __name__ == '__main__':

    myDb = DataBase()
    myDb.add_sensor_type('Test')

    for type in myDb.get_sensor_types():
        print(type.id, type.typename)

A: Instead of nesting classes, try inheritance.  This post has some fairly decent information on how to use inheritance and metaclasses in Python.
Looking at the quickstart example for peewee, does something like this work for you?
import peewee

class BaseModel(peewee.Model):
    def __init__(self, db):
        super(BaseModel, self).__init__()
        Meta.database = db

    class Meta:
        database = None

class SensorType(BaseModel):
    def __init__(self, db):
        super(SensorType, self).__init__(db)

    name = peewee.CharField(max_length=255, unique=True)

class DataBase():
    def __init__(self, filename='sensors.db'):
        self.db = peewee.SqliteDatabase(filename)
        self.sensor_type = SensorType(self.db)
        self.db.connect()
        self.db.create_tables([self.sensor_type], safe=True)

    def add_sensor(self, typeName):
        type, created = self.sensor_type.get_or_create(name=typeName)
        return type, created

    def get_sensors(self):
        return self.sensor_type.select().order_by(self.sensor_type.name)

if __name__ == '__main__':
    db = DataBase()

    db.add_sensor('Test')
    [print(type.name) for type in db.get_sensors()]

Mess around with the model's __init__ method to see if you can pass a database instance upon initialization.
I would stay far away from defining a class inside a method.
I hope this helps!

A: I ended up using this approach from peewee documentation. It works and I avoid the nested classes:
import peewee as pe
database = pe.SqliteDatabase(None)

class BaseModel(pe.Model):
    class Meta:
        database = database

class SensorType(BaseModel):
    name = pe.CharField(max_length=255, unique=True)

class DataBase():
    def __init__(self, filename='sensors.db'):
        database.init(filename)
        self.sensor_type = SensorType()
        database.connect()
        database.create_tables([self.sensor_type], safe=True)

if __name__ == '__main__':
    db = DataBase('test.db')


text:
Holy See's Address to Panel on Palestinian Rights / "Suffering in the End Affects Everyone"
Here is the March 22 address given by Monsignor Pietro Parolin to a conference organized by the U.N. Committee for the Exercise of the Inalienable Rights of the Palestinian People.
Here is the March 22 address given by Monsignor Pietro Parolin to a conference organized by the U.N. Committee for the Exercise of the Inalienable Rights of the Palestinian People. Monsignor Parolin is the undersecretary for relations with states of the Vatican Secretariat of State.
The conference was held last Thursday and Friday in Rome.
Mr. President,
I have the honor of bringing the Holy See's greetings and good wishes to all who are taking part in this International Conference, being held here in Rome at the headquarters of the FAO.
This conference, organized by the United Nations Committee for the Exercise of the Inalienable Rights of the Palestinian People, is aimed at giving fresh impetus to the reflection and the involvement of the international community, religious confessions, parliamentary groups and civil society, in order to determine the challenges which must be faced and the approach which should be adopted so as to contribute to the building of peace between Israelis and Palestinians.
This conference is taking place as the Government of National Unity set up by the Palestinian Authority on Saturday last, March 17, takes its first steps. It is surely positive that this government is the product of a compromise between the principal Palestinian political groups.
It brings to an end several months of severe, armed and violent conflict, which resulted in many victims, often innocent ones, among the Palestinian people who have already suffered so much.
The international community is hopeful that the new government will be an authoritative and trustworthy interlocutor, capable of leading its people, with a sense of responsibility and realism, to the conclusion of a just peace with the Israelis — who have the right to live in peace in their own state (cf. Address of Pope Benedict XVI to the Diplomatic Corps accredited to the Holy See, Jan. 8, 2007) — and to the setting up of the free, independent and sovereign state which all hope to see established for the Palestinians.
The Holy See has always followed with particular attention the events of recent decades: Thousands of Catholics live in this land, which we like to call the "Holy Land" since it preserves the living memory of the events which have marked our history of salvation. Millions of Catholics and Christians throughout the world look to this land, with the hope of being able to travel there on pilgrimage.
Recently Pope Benedict XVI himself wished to emphasize this attentiveness by addressing a letter to the Catholics who live in the Middle East.
He noted that "in the present circumstances, marked little by light and too much by darkness, it is a cause of consolation and hope for me to know that the Christian communities in the Middle East, whose intense suffering I am well aware of, continue to be vital and active communities, resolute in bearing witness to their faith with their specific identity in the societies in which they are situated. They wish to contribute in a constructive manner to the urgent needs of their respective societies and the whole region."
In this letter, the Pope sets out in concrete detail how this constructive contribution should take place. I take the liberty of quoting the relevant passages, since these contain very useful recommendations as to the spirit in which the work of creating the conditions for a true and just peace between Israelis and Palestinians should be undertaken:
"The daily news coming from the Middle East shows a growth of alarming situations, seemingly with no possible escape. They are events which naturally give rise, in those involved, to recriminations and rage, leading them to thoughts of retaliation and revenge.
"We know that these are not Christian sentiments; to give in to them would leave us callous and spiteful, far from that 'gentleness and lowliness' which Jesus Christ proposed to us as the model of behavior.
"Indeed, we could lose the opportunity to make a properly Christian contribution to the solution of the grave problems of our time. It would not be at all wise, especially now, to spend our time asking who has suffered the most or presenting an account of injustices suffered, listing the reasons which reinforce one's own argument.
"This has often happened in the past, with results which to say the least were disappointing. Suffering in the end affects everyone, and when one person suffers he should first of all wish to understand how much someone else in a similar situation suffers.
"Patient and humble dialogue, achieved through listening to each other and being intent upon understanding someone else's situation has already borne positive results in many countries previously devastated by violence and revenge. A little more trust in the compassion of others, especially those suffering, cannot but bear efficacious results.
"Today, many parties rightly plead for this interior disposition. … Through you, my dearly beloved, I wish to make an appeal to your fellow citizens, men and women of the different Christian confessions, of different religions and all who honestly seek peace, justice and solidarity by listening and sincere dialogue.
"I say to you all: Persevere with courage and trust! I appeal to those who hold positions of responsibility in guiding events to cultivate that sensitivity, attentiveness and closeness which surpass schemes and strategies so that they can build societies that are more peaceful and just, truly respectful of every human being."
I conclude my brief greeting by wishing every success to this conference. In the name of the Holy See, I wish to state my firm conviction that the different religious confessions present in the Holy Land can make a decisive contribution to the relaunching of peace talks between Israelis and Palestinians, precisely by working to promote among their members the attitudes which I mentioned.
Fadi Hanna 2016-10-24T07:28:59+00:00 March 27th, 2007|Categories: News|

redpajama_set_name: RedPajamaCommonCrawl


text:
Manufacturing + Logistics
Housing + Mixed-Use
Business Development, Administration, & IT
Project Tag: event center
Simon Skjodt Assembly Hall
When Indiana University set out to improve the iconic Assembly Hall, they prioritized the preservation of the original aesthetic while challenging the design team to develop a bold, yet respectful expansion that closely aligned with the architectural character of the original structure. Contextual influences drove a design solution that integrated the new addition into the existing structure holistically with a reverent architectural expression that closely relates to the original.
A new atrium space allows views between the entry and main concourse. This is the center of the new space and features a reinvented version of Athlete's Hall and a panoramic window allowing views into the arena. The new arrival area supports existing traditions while offering a space for new traditions, events, and ceremonies to take place. The new entry is conveniently located, and visible escalators create a clear and efficient means for moving spectators through the space into the arena. A new Box Seat Club offers an exceptional viewing experience of events. CSO collaborated with SmithGroup to complete this project.
CSO subsequently completed the Roberts Family Indiana Basketball Team Center and Mark Cuban Center for Sports Technology located within Assembly Hall.
Bulldog Park
Bulldog Park includes a National Hockey League-sized ice rink, an outdoor amphitheater, and a two-story building. The area between the building and ice skating rink is designed to serve various seasonal purposes and includes a splash pad feature for summer use. The ice rink is the only outdoor NHL-sized ice rink in Northwest Indiana.
The ice rink is designed for use at temperatures up to 45 degrees. This enables the City to offer ice-skating without having to wait for the temperature to drop to freeze the ice naturally.
The city anticipates hosting various events at the venue including a farmer's market, car shows, and performances. They also expect that the public will use the various spaces for private events such as wedding receptions.
The two-story building provides a new home for the city's Special Events and Parks Department offices and Senior Center.
CURIS Design to Deliver Transformative, Resilient Healthcare Design
CSO Ranks Among Top 300 Firms in Architectural Record's Annual List
CSO Projects Honored with Awards
8831 Keystone Crossing