A folder can contain following -- One or more files -- One or more folders (called subfolders) -- Link to parent directory. The one referred to as a dot (.) in Windows OS
class Folder(db.Model): files = db.ListProperty(db.Key) subfolders = db.ListProperty(db.Key) parentfolder = db.SelfreferenceProperty() The *files* attribute will contain a list of Keys of files which are inside this folder. The *folders* attribute will contain a list of Keys of folders which are inside this folder The *parent* will contain a reference to the parent folder. This schema will work good on acyclic directory structure. For a more broader view, you can have three Models -- File -- Folder -- Folder2File The last Model will contain a many-to-many relationship between files and folders > "subfolders = db.ListProperty(Folder)" > seems not working. subfolders = db.ListProperty(Folder) is syntactically wrong. A ListProperty can not refer to a Model. Cheers, -- Pranav Prakash "This life is more than ordinary" > > 2009/5/6 Pranav Prakash <pra...@gmail.com> > > > > > class Folder(db.Model): > > name = db.StringProperty() > > subfolders = db.ListProperty(File) > > parent = db.SelfReferenceProperty() > > > This is how folder can be implemented. A folder must know what all > > files are child. Also a folder must know the parent folder (folders in > > case of cyclic dir structure). > > > Apart from this, you might also implement Linux inode system in a > > model, for book keeping. > > > On May 6, 5:41 am, Tim Hoffman <zutes...@gmail.com> wrote: > > > You will need to create a Folder entity > > > It will need to know it's children, and you will need to support > > > some form of url traversability to walk the folder heirarchy. > > > > I am doing that with zope3 components on gae > > > > Django doesn't normally do url traversing, but has a regex match to > > > method > > > > Do you really need a folder heirarchy, have you gone down that path > > > because you are just trying to > > > replicate a filesystem, with out really needing those semantics ? > > > > If you really want this sort of functionality you might want to look > > > at repoze.bfg it is just been > > > made useable under gae (and is zope 3 based though much simpler) and > > > does support inherintly > > > the notion of url traversal over an object model/graph > > > > Rgds > > > > T > > > > On May 6, 6:34 am, Shedokan <shedok...@gmail.com> wrote: > > > > > I am porting my WebOS(Shedokan OS) to python from php so I can use it > > > > og GAE and I came to the stage where I need to read and write files. > > > > > And after a lot of searching I found out that I cannot create files or > > > > write to files. > > > > here is my code: > > > > > from google.appengine.ext import db > > > > > class File(db.Model): > > > > filename = db.StringProperty(multiline=False) > > > > filedata = db.BlobProperty > > > > date = db.DateTimeProperty(auto_now_add=True) > > > > > def createFile(fileName, content): > > > > if fileName=='' or content=='': > > > > return > > > > file = File() > > > > file.filedata = content > > > > file.filename = fileName > > > > file.put() > > > > > def getFile(fileName): > > > > > if fileName=='': > > > > return > > > > return db.GqlQuery('SELECT * FROM File WHERE filename= > > :1',fileName) > > > > > any way to make this work with a folder structure? > > > > > also I want to note that I started learning python just about 3 days > > > > ago, so I think I'm a begginer. > > > > > thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---