Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3362 Lượt xem

Hi,

I'm trying to implement a feature in my custom module that auto fills a selection field with data (gathers from GET requests to alfresco API to list site's directory)


I've tried the following but did not work :

......
my_site = fields.Char("Site")
my_selection = fields.Selection(selection="_get_selection",string="Directory")
def _get_selection(self) : 
    if self.site_is_reachable() :
        link = "https://alfresco.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/sites/"+
                self.my_site+
                "/documentLibrary" # self.my_site si not accessible here
         passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
         passman.add_password(None, link,user, pwd)
         authhandler = urllib2.HTTPBasicAuthHandler(passman)
         opener = urllib2.build_opener(authhandler)
         urllib2.install_opener(opener)
         pagehandle = urllib2.urlopen(link)
         return self.handle_response(pagehandle.read()) # handle the response, extract the names and return a list of tuples
.......

               

The issue in the code is that the called function in "Selection" :_get_selection, does not have the current record, i can't figure out how to passe it as argument or through context.

Any idea to make it work ?

Thank you :)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

UP +1

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
13118
1
thg 5 16
17407
2
thg 9 23
9312
2
thg 11 23
5348
2
thg 5 19
31633