OK so I am working on this technique what do you think?

API File: youadAPI.adviewer_api
from gluon import *

class AdViewerEngine:
   class tables:
        AdReports = 'adreports'
        Ads = 'ads'
        AdveiwerSettings = 'adviewer_settings'
        Keywords = 'keywords'
        AdKeyword = 'ad_keyword'
        AdReport = 'ad_report'
        DailyAdViews = 'dailyadviews'
        YearlyAdViews = 'yearlyadviews'
        ViewedAds = 'viewedads'

   def __init__(self, db, mail, tables = [], migrate=True,
fake_migrate=False):
       self.db = db
       self.define_tables(tables, migrate, fake_migrate)

   def define_tables(self, tables = [], migrate=True, fake_migrate=False):
        db = self.db
        if (not tables or tables and AdViewerEngine.tables.AdReports in
tables) and AdViewerEngine.tables.AdReports not in db.tables:
            print "Making table", AdViewerEngine.tables.AdReports
            db.define_table(
                AdViewerEngine.tables.AdReports,
                ...
                migrate=migrate,
                fake_migrate=fake_migrate
            )

        if (not tables or tables and AdViewerEngine.tables.Ads in tables)
and AdViewerEngine.tables.Ads not in db.tables:
            db.define_table(
                AdViewerEngine.tables.Ads,
                ...
                migrate=migrate,
                fake_migrate=fake_migrate
            )

controller:
def index():
    from youadAPI.adviewer_api import AdViewerEngine
    adviewer_engine = AdViewerEngine(db, mail,
        tables = [
            AdViewerEngine.tables.Ads,
            AdViewerEngine.tables.ViewedAds
        ],
        migrate=False
    )

    db(db[AdViewerEngine.tables.Ads].id == 5).select().first()  # Things
like this will be moved into adviewer_api at some point

This works by only creating the tables that I define per action. Do you for
see any problems using this method?

On Sat, May 12, 2012 at 9:06 AM, Bruce Wade <bruce.w...@gmail.com> wrote:

> Yeah I am going through all my controllers right now to see if I can use
> the folder solution. Which way would be faster? Folders or modules?
>
>
> On Sat, May 12, 2012 at 8:52 AM, Anthony <abasta...@gmail.com> wrote:
>
>> On Saturday, May 12, 2012 10:51:59 AM UTC-4, Bruce Wade wrote:
>>>
>>> I am starting to think the design loading everything in models with
>>> every request, all though makes for rapid development isn't a very good
>>> design. Maybe for common settings in witch case the folder shouldn't be
>>> called models.
>>
>>
>> Note, if you have some models that are needed only for particular
>> controllers or functions, you can execute them conditionally based on the
>> controller (and optionally the function) by using sub-folders, as described
>> here: http://web2py.com/books/default/chapter/29/4#Workflow. Otherwise,
>> you can put them in modules and import them.
>>
>> Anthony
>>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

Reply via email to