well almost perfectly. below is my code: app=community.name db_path = os.path.join(request.folder,'databases',app) if not os.path.exists(db_path): os.mkdir(db_path) mtgdb=DAL('sqlite://%s/storage.sqlite' % app)
mtgdb.define_table( 'thoughts', Field('description','text'), Field('author','string'), Field('votes','integer') ) mtgdb.thoughts.description.requires = IS_NOT_EMPTY() the result is a new sub-folder created in the databases folder of my app with the name of the ciommunity. The problem is the "thoughts" table is not created in the community sub-folder, but rather the databases folder. I looked up the syntax of the define_table method, buit do not see a way to override the location. On Aug 7, 9:38 am, "david.waldrop" <david.wald...@gmail.com> wrote: > worked perfectly. I am a happy camper. One thing I am uneasy with is > knowing if it's "ok" to define databases and tables in a controller, > where to put inport statements, and in general how to partition code. > Is there a particilarly good app you would recccomend as a reference > or a place to read about web2py application architecture??? > > On Aug 7, 7:39 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > instead of > > > db=DAL('sqlite://storage.sqlite') > > > do > > > app='...' # somehow determine which name > > db_path = os.path.join(request.folder,'databases',app) > > if not os.path.exists(db_path): os.mkdir(db_path) > > db=DAL('sqlite://%s/storage.sqlite' % app) > > > On Aug 7, 6:33 am, "david.waldrop" <david.wald...@gmail.com> wrote: > > > > I have now got the url working via DNS as suggested. But encountered > > > another problem. I would like for each community to have a separate > > > database. Whenever I creaet a new community database and > > > corresponding tables they are physically intermixed with teh SQLLite > > > storage folder of the main/global database. How can I get the current > > > storage location and create new folders in the OS to house the > > > corresponding database and table files. Below is an illustration of > > > what I would the resulting file structure to be want: > > > > MyAPP > > > databases > > > storage.sqlite > > > c2628476264624626_communities.table > > > <<<other global tables>>>> > > > My first community > > > storage.sqlite > > > d32753728973493784_events.table > > > <<<other tables related to "My first community" > > > Fox Hills Swim Club > > > storage.sqlite > > > e98738957375937_events.table > > > > Note: Each community will have the same tables (bit obviously with > > > different data) and I realize this is specific to sqlite (which is ok > > > for what I am doing). > > > > I think that what I do not know how to do is retrieve the current > > > storage location (i.e. folder) and how to specif the location where > > > DAL creates a new database. > > > > Thanks in advance for your assistance. > > > > On Jul 24, 11:56 am, Iceberg <iceb...@21cn.com> wrote: > > > > > Some domain register supports "wild chars" in your domain name, so all > > > > requests to "*.yourdomain.com" can reach your site. > > > > > If you prefer the other style, try web2py/route.py > > > > > On Jul 24, 10:59pm, "david.waldrop" <david.wald...@gmail.com> wrote: > > > > > > Thnaks for the reply, but I think I was not clear. I se form you > > > > > example how to dynamically point to a seperate DB. But regarding the > > > > > url, users can create communities on the fly and henei I would like to > > > > > avoid having to register each one with DNS. The main use behined a > > > > > seperate URL is to make it easy for communities to be shared. So for > > > > > example I could inviet my neoighbor by simply email a link. They in > > > > > turn coud do the same and invite others. I was thinking of a link > > > > > like this: > > > > > >www.mydomain.com/mycommunity1 orwww.mydomain.com\tallyhoswimclub > > > > > > where the suffix uniquely identifies the community. I see that web2py > > > > > controls the url naming and am not sure how this scheme would impact > > > > > the typical url suffixes that actuall provide functionality (i.e. > > > > > about, leit, new posing, etc.) and ofetn related to a view and.or > > > > > controler. > > > > > > Any ideas? > > > > > > On Jul 22, 6:47 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > Thanks > > > > > > > you can do this. register a domain like mydomain.com and access it > > > > > > as > > > > > > >http://mycommunty.mydomain.com > > > > > > > in the model file you can do: > > > > > > > community = request.env.host_name.split('.')[0] > > > > > > db=DAL('sqlite://storage.%s.sqlite' % community) > > > > > > > and that should be all you need. > > > > > > > On Jul 22, 1:58 pm, "david.waldrop" <david.wald...@gmail.com> wrote: > > > > > > > > All, I just discovered this amazing framework and am immediately > > > > > > > switching to it (from adobe) for a current project I am working > > > > > > > on. > > > > > > > It is quite different from the way I have built solutions in the > > > > > > > past. Here is the basic structure of how I need to approach the > > > > > > > problem: > > > > > > > > 1) I want a user to log in and create a community based topic. > > > > > > > > 2) This community topic should have a separate URL and database. > > > > > > > I > > > > > > > desire this for scaleability and privacy. I asume the url will be > > > > > > > either the community topic name (or a GUID of some type, and am OK > > > > > > > with this) suffixed to my domain. > > > > > > > > 3) The organizer can freely share the url with others in their > > > > > > > neighborhood. > > > > > > > > 4) All users will be required to register and login in. > > > > > > > > 5) Users can participate in multiple community topics. I think > > > > > > > this > > > > > > > means there is a central database storing community topics and > > > > > > > participating users, thereby allowing the user to see a list of > > > > > > > community topics in which they are participating when they log in. > > > > > > > When they select a community topic (ideally represented by a URL > > > > > > > to > > > > > > > aid in easily sharing) the app must somehow switch the underlying > > > > > > > database. > > > > > > > > I am getting the hang of implementing the functionality within a > > > > > > > community, but have no real idea how to fulfill the above > > > > > > > requirements. Any thoughts or suggestions would be greatly > > > > > > > appreciated. Again,WOW, I cannot believe I have been unaware of > > > > > > > web2py!!!!!- Hide quoted text - > > > > > > > - Show quoted text -