Calling Python Functions from Non-hooks

Micah Ransdell mjr578 at gmail.com
Thu Feb 5 13:42:05 CST 2009


I have narrowed it down to hgwebdir_mod.py. It seems that when checking for
permissions in read_allowed that the call to ui.configlist isn't actually
loading my extension and properly wrapping the call to ui.config. Any advice
on how to get my extension to be loaded by hgwebdir_mod?

Micah

On Wed, Feb 4, 2009 at 6:39 PM, Micah Ransdell <mjr578 at gmail.com> wrote:

> Matt,
>
> I got my extension to work partially (thank you again), but I have run into
> a problem.
>
> My extension piggybacks on the ui.config method similar to the zeroconf
> extensions that you referenced, except I am having trouble with hgweb
> reading things properly. The extension is just a simple ldap lookup of a
> group specifed in the (allow|deny)_(push|read) configuration section. It
> takes the group and finds all the members in that ldap group then returns
> those usernames instead of the ldap group. This works great for allow_push,
> but allow_read doesn't seem to be working properly. I can browse the repo,
> but it won't show up in the list of repositories for some reason. Even
> stranger still, when I put the ldap group in the deny_read section it
> actually shows the repo in the list, yet when I click on it to browse, I get
> an error saying I am not allowed to read it.
>
> I have uploaded my code to bitbucket in case you want to see if I am making
> a simple mistake:
> https://bitbucket.org/mjr578/allow_ldap_ext/src/tip/allow_ldap/. Thank you
> for any help you can provide.
>
> Micah
>
> On Tue, Feb 3, 2009 at 2:30 PM, Matt Mackall <mpm at selenic.com> wrote:
>
>> On Tue, 2009-02-03 at 13:47 -0800, Micah Ransdell wrote:
>> > Is it possible to call a python function from a non-hook in a hgrc
>> > file? For example, I am wanting to return a list of users that are
>> > allowed to read a repository (under allow_read), but I want to do that
>> > dynamically. Is it possible to call a python function in much the same
>> > way that we can call them for hooks? Obviously I could periodically go
>> > through and update the hgrc file with the users who are allowed to
>> > read the repo through an automated process, but I would prefer the
>> > check to happen when someone accesses the repository. Any suggestions?
>>
>> This is a great place to use an extension. Look at how
>> hgext/zeroconf/__init__.py adds to [paths] dynamically, starting at line
>> 43:
>>
>> def config(orig, self, section, key, default=None, untrusted=False):
>>    if section == "paths" and key.startswith("zc-"):
>>        for n, p in getzcpaths():
>>            if n == key:
>>                return p
>>    return orig(self, section, key, default, untrusted)
>>
>> def configitems(orig, self, section, untrusted=False):
>>    r = orig(self, section, untrusted)
>>    if section == "paths":
>>        r += getzcpaths()
>>    return r
>>
>> extensions.wrapfunction(ui.ui, 'config', config)
>> extensions.wrapfunction(ui.ui, 'configitems', configitems)
>>
>> --
>> http://selenic.com : development and support for Mercurial and Linux
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20090205/8b82d541/attachment.htm 


More information about the Mercurial mailing list