Yes, exactly as you've said, all of the classes except mixins corresponds to a table and Shots.id -> Tasks.id -> Entities.id -> SimpleEntities.id all are foreign keys to the next. So querying a SimpleEntity will may return a mixed list of other entity types, this is the power of SQLAlchemy and Joined Table Inheritence model and it is working very well.
Let me point some other important information, because Assets, Shots and Sequences are derived from Tasks, creating a bunch of assets and shots or sequences and querying them by using Task class (using Task.query) is working very nicely. You do not care about if the data is an Asset or Shot until you need to know it. This helped us a lot when writing the web templates, we just wrote a template for the Task and it worked well with the other types. Also another point Shots are not in anyway forced to be related to a Sequence. In fact a Shot can be connected to more than one Sequence (think about a shot is being the flashback cut in another sequence so it is appearing twice in the movie etc.). Because of the freedom in the parent/child relation of the Tasks, you can setup things like a Shot is the parent of an Asset or the reverse like an Asset is the parent of a Shot or something meaningless like a Shot is a parent of a Sequence etc. you are free to do that. That brings a lot of power when customizing the hierarchy. This feature alone makes Stalker to fit in a lot different workflows. E.Ozgur Yilmaz eoyilmaz.blogspot.com On Mon, May 12, 2014 at 8:03 AM, Chad Dombrova <[email protected]> wrote: > Another question regarding sqlalchemy and the inheritance model: > http://pythonhosted.org/stalker/design.html#inheritance-diagram > > which of these classes correspond to a table in the database? all but the > mixins? > > does each table have a foreign key to the 'id' field of its super-class > table? for example, does the Shot table have a foreign key to Task.id, and > the Task table have a foreign key to Entity.id, and so on? > > thanks, > chad. > > > > On Sun, May 11, 2014 at 1:04 PM, Erkan Özgür Yılmaz <[email protected]>wrote: > >> >> >> E.Ozgur Yilmaz >> eoyilmaz.blogspot.com >> >> >> On Sun, May 11, 2014 at 9:46 PM, Chad Dombrova <[email protected]> wrote: >> >>> Thats very interesting stuff, I was planing to use gevent along with >>>> pyramid but I think I also should heavily evaluate Meteor (though this >>>> mongodb <-> sqlalchemy is scarering me a little bit). >>>> >>> So far the mongodb <---> postgresdb prototype seems to be working well. >>> once we have the connector in a testable state, I'll let you know. Even >>> without meteor, I see the ability to have simultaneous access your data via >>> SQL or NoSQL as a form of future-proofing. >>> >>> Meteor seems to have a lot of momentum right now. To get an idea of its >>> meteoric rise (pun intended), the repo has been starred 12,458 times on >>> github and has almost 1,800 forks in just a few years (compare that to >>> Pyramid's 1,372 and 472, and you get an idea of relative adoption). In >>> 2012 they got a first round of venture capital to the tune of $11.2 >>> million<https://www.meteor.com/blog/2012/07/25/meteors-new-112-million-development-budget>, >>> backed by some huge names. >>> >>> >> Those are great numbers and I would be appreciated to be informed about >> the state of the mongodb to postgresdb bridge. >> >> >>> >>> One more question about stalker. I was looking at this part of the >>> tutorial: >>> http://pythonhosted.org//stalker/tutorial.html#part-vi-asset-management >>> >>> A FilenameTemplate defines how to generate a path for a Version >>> instance. How do you go the other direction: lookup a Version instance and >>> its associated task from a file path? >>> >>> >> The path of a Version instance is stored in DB with the Repository path >> is stripped out, so it is basically a repository root relative path. >> >> What I do when I have a full path is, first to find the Repository, strip >> the repo parth from the full path and then search for a Version with that >> string. >> >> I do it in Anima as follows (this is a snippet from the >> anima.env.base.EnvironmentBase class): >> >> class EnvironmentBase(object): >> >> @classmethod >> def find_repo(cls, path): >> """returns the repository from the given path >> >> :param str path: path in a repository >> :return: stalker.models.repository.Repository >> """ >> # first find the repository >> from stalker import Repository >> >> repos = Repository.query.all() >> found_repo = None >> for repo in repos: >> if path.startswith(repo.path) \ >> or path.startswith(repo.windows_path) \ >> or path.startswith(repo.linux_path) \ >> or path.startswith(repo.osx_path): >> found_repo = repo >> break >> return found_repo >> >> def trim_repo_path(self, path): >> """Trims the repository path value from the given path >> >> :param path: The path that wanted to be trimmed >> :return: str >> """ >> # get the repo first >> repo = self.find_repo(path) >> >> if not repo: >> return path >> >> # then try to trim the path >> if path.startswith(repo.path): >> return path[len(repo.path):] >> elif path.startswith(repo.windows_path): >> return path[len(repo.windows_path):] >> elif path.startswith(repo.linux_path): >> return path[len(repo.linux_path):] >> elif path.startswith(repo.osx_path): >> return path[len(repo.osx_path):] >> return path >> >> def get_version_from_full_path(self, full_path): >> """Finds the Version instance from the given full_path value. >> >> Finds and returns a :class:`~stalker.models.version.Version` >> instance >> from the given full_path value. >> >> Returns None if it can't find any matching. >> >> :param full_path: The full_path of the desired >> :class:`~stalker.models.version.Version` instance. >> >> :return: :class:`~stalker.models.version.Version` >> """ >> # convert '\\' to '/' >> full_path = os.path.normpath(full_path).replace('\\', '/') >> >> # trim repo path >> full_path_trimmed = self.trim_repo_path(full_path) >> logger.debug('full_path_trimmed: %s' % full_path_trimmed) >> >> from stalker import Version >> >> # try to get a version with that info >> version = Version.query\ >> .filter(Version.full_path == full_path_trimmed).first() >> return version >> >> >> Even though it is working great, I don't think that it is the best way of >> doing it, I should probably implement a nicer SQL query to Stalker and be >> sure that the resultant Version is really stored in that repository >> (meaning version.task.project.repository == repo) >> >> >> >>> Also I'm not sure that I was clear about the docs, the auto generated >>>> docs for Stalker are in http://pythonhosted.org/stalker/ just slide >>>> down to the very end of the page to start seeing the api doc links. >>> >>> >>> ah, whoops. I stopped scrolling when I got to the changelog. >>> >>> chad. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/python_inside_maya/CAGq9Q7GTSdgaosdNrsHr2tepamMpWVVhEv_1e-o3EN-8LC-8Ng%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAGq9Q7GTSdgaosdNrsHr2tepamMpWVVhEv_1e-o3EN-8LC-8Ng%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/CAGNmyx6rD68Xbf-CvLbPMhnjhhtZfijTajHNq36bnEYRsCEKEw%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAGNmyx6rD68Xbf-CvLbPMhnjhhtZfijTajHNq36bnEYRsCEKEw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAGq9Q7GHiFK8n%2B8JgcKmam3B9RLcpmDRh6RO8KXyfpoSDoPT2Q%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAGq9Q7GHiFK8n%2B8JgcKmam3B9RLcpmDRh6RO8KXyfpoSDoPT2Q%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGNmyx742NAKn_AncS9ZuswpMa%3D6BvP39WNy%2Bf4K5ev3Bb3bvQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
