On Oct 25, 2009, at 9:35 AM, Mike Hull wrote:

> The library is fairly modular, I had planned something along the lines
> of:
>
>
> ./dbcontrol/dbcontrol.py
> class DBController(Borg):
>
>  def isUsingDB():
>       #read someconfigfile to determine whether db in use
>
>
>
> ./core/__init__.py
> from dbcontrol/dbcontrol import DBController
> if DBController.isUsingDB():
>   from core.morphology_DB import Morphology
>   #And all other objects to be stored in db
> else:
>   from core.morphology_NoDB import Morphology
>   #And all other objects not to be stored (freestanding)
>
>
> ./core/morphology_NoDB.py
> class Morphology():
>    def __init__(self,name, otherparams):
>        self.name = name
>        self.otherparams = otherparams
>    def MyMethod(self)
>        #do stuff
>
> ./core/morphology_DB.py
> class Morphology():
>        name = Column(...)
>        otherparams = Column(...)
>    def __init__(self,name, otherparams):
>        pass
>    def MyMethod(self)
>        #do stuff
>
>
>
> Is this the way people would recommend going about this problem??
> Any thoughts would be gratefully recieved; before I embark on possibly
> doubling the size of my class hierachy :-)

oh I wouldn't declare every class twice.  At the very least the use  
case you describe is more appropriate for the datamapper pattern,  
meaning you wouldn't use declarative.  Your "db" package would just  
issue mapper() calls to each class.    But keep in mind that SQLAs  
instrumenation does provide behaviors to classes as well, things like  
relation and backref and such.   The pattern of "my objects are the  
same with and without being mapped" might be tricky unless you're  
keeping the usage patterns very simple.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to