Ejemplo n.º 1
0
    def listpagelets(self,sessionuserid,pgts):
        # To simulate the query of a database , just adding known pagelet ids into a tuple

        print "\nPagelet List"
        printstr =""
        newrow = {}
        colhead =[]
        for pgt in pgts:
            fieldset = pgt.acl(sessionuserid)
            newdict ={}
            for field in fieldset.keys():
                if 'r' in list(fieldset[field]) or (fieldset[field] =='-w' and pgt.isauthor(sessionuserid)==True): 
                    fld = storedata.fetch_field(field)
                    newdict[fld] = storedata.fetch_field_value(field, pgt.id)
                    if fld not in colhead:
                        colhead.append(fld)
            newrow[pgt.getid()] = newdict 
        printstr += "   "
        for eachcol in colhead:
            printstr += eachcol + "  "
        printstr += "\n"
        for eachp in newrow.keys():
            printstr += eachp + "  "
            p = newrow[eachp]
            for eachcol in colhead:
                if eachcol in p.keys():
                    printstr += str(p[eachcol]) + "  "
            printstr += "\n"
        print printstr
Ejemplo n.º 2
0
    def view(self,sessionuserid):
        '''
        For fields in cs, show readable fields
        '''
        fieldset = self.acl(sessionuserid)
        #get field's by ID, retrieve the value associated and return
        #here's where persistence will come into play first
        #print "\nPagelet Field Access list" 
        print "\nPagelet View for ", sessionuserid
        for field in fieldset.keys():
            fld = storedata.fetch_field(field)
#fld = cPickle.load(open(field + ".obj",'rb'))
            if 'r' in list(fieldset[field]) or (fieldset[field] =='-w' and self.isauthor(sessionuserid)==True): 
                print "\n" + str(fld) + storedata.fetch_field_value(field, self.id)
Ejemplo n.º 3
0
 def edit(self,sessionuserid):
     '''
     For fields in cs, show editable fields
     '''
     print "pagelet",sessionuserid
     fieldset = self.acl(sessionuserid)
     list_of_fields = []
     for field in fieldset.keys():
         var = storedata.fetch_field(field)
         if 'w' in list(fieldset[field]):
             ans = raw_input(var)            
             list_of_fields.append(dict({field:ans}))
         else:
             list_of_fields.append({field: storedata.fetch_field_value(field, self.id) })
     storedata.update_field(self.sessionuser, list_of_fields, self.id)