Subversion Repositories SmartDukaan

Rev

Rev 1301 | Rev 1859 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1301 Rev 1845
Line 176... Line 176...
176
    enabled = Field(Boolean)
176
    enabled = Field(Boolean)
177
    widget_items=OneToMany("WidgetItem")
177
    widget_items=OneToMany("WidgetItem")
178
    using_options(shortnames=True)
178
    using_options(shortnames=True)
179
    using_table_options(mysql_engine="InnoDB")
179
    using_table_options(mysql_engine="InnoDB")
180
 
180
 
-
 
181
class MasterAffiliate(Entity):
-
 
182
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
183
    name = Field(String(100), unique=True)
-
 
184
    affiliates = OneToMany("Affiliate")
-
 
185
    using_options(shortnames=True)
-
 
186
    using_table_options(mysql_engine="InnoDB")
-
 
187
 
-
 
188
class Affiliate(Entity):
-
 
189
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
190
    master_affiliate = ManyToOne("MasterAffiliate")
-
 
191
    name = Field(String(100), unique=True)
-
 
192
    url = Field(String(200))
-
 
193
    trackers = OneToMany("Tracker")
-
 
194
    using_options(shortnames=True)
-
 
195
    using_table_options(mysql_engine="InnoDB")
-
 
196
 
-
 
197
class Tracker(Entity):
-
 
198
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
199
    affiliate = ManyToOne("Affiliate")
-
 
200
    tracklogs = OneToMany("TrackLog")
-
 
201
    using_options(shortnames=True)
-
 
202
    using_table_options(mysql_engine="InnoDB")
-
 
203
 
-
 
204
class TrackLog(Entity):
-
 
205
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
206
    tracker = ManyToOne("Tracker")
-
 
207
    user_id = Field(Integer)
-
 
208
    event = Field(String(100))
-
 
209
    url = Field(String(200))
-
 
210
    data = Field(String(200))
-
 
211
    using_options(shortnames=True)
-
 
212
    using_table_options(mysql_engine="InnoDB")
-
 
213
 
181
def initialize(dbname='user'):
214
def initialize(dbname='user'):
182
    #metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
215
    #metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
183
    engine = create_engine('mysql://root:shop2020@localhost/' + dbname, pool_recycle=7200)
216
    engine = create_engine('mysql://root:shop2020@localhost/' + dbname, pool_recycle=7200)
184
    metadata.bind = engine
217
    metadata.bind = engine
185
    metadata.bind.echo = True
218
    metadata.bind.echo = True