E.Ozgur Yilmaz
eoyilmaz.blogspot.com

On Sun, May 11, 2014 at 9:46 PM, Chad Dombrova <chad...@gmail.com> 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 python_inside_maya+unsubscr...@googlegroups.com.
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAGNmyx6rD68Xbf-CvLbPMhnjhhtZfijTajHNq36bnEYRsCEKEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to