当前位置: 首页>>代码示例>>Python>>正文


Python GetDataFolder.unrestrictedTraverse方法代码示例

本文整理汇总了Python中libDatabase.GetDataFolder.unrestrictedTraverse方法的典型用法代码示例。如果您正苦于以下问题:Python GetDataFolder.unrestrictedTraverse方法的具体用法?Python GetDataFolder.unrestrictedTraverse怎么用?Python GetDataFolder.unrestrictedTraverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libDatabase.GetDataFolder的用法示例。


在下文中一共展示了GetDataFolder.unrestrictedTraverse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetCategoryList

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def GetCategoryList(objHere):
    strResult = ""
    
    objCategories = GetDataFolder(objHere, 'MCIBookCategory')
    lstIds = GetOrderedIds(objCategories, 'MCIBookCategory')
    for strId in lstIds:
        objSubCategories = objCategories.unrestrictedTraverse(strId)
        lstSubIds = GetOrderedIds(objSubCategories, 'MCIBookCategory')
        objCategory = objCategories.unrestrictedTraverse(strId)
        strResult = strResult + CategoryRow("<b>%s</b>" % objCategory.CategoryName, strId, "ListForCategory", objCategory.BooksInCategory, 0, "BookCategory")
        for strSubId in lstSubIds:
            objSubCategory = objCategory.unrestrictedTraverse(strSubId)
            strResult = strResult + CategoryRow(objSubCategory.CategoryName, strSubId, "ListForCategory", objSubCategory.BooksInCategory, 1, "BookCategory")
        strResult = strResult + """<tr><td colspan="3">&nbsp;</td></tr>"""
    return strResult        
开发者ID:CoachCoen,项目名称:ECL,代码行数:17,代码来源:MCIBooks.py

示例2: GetMemberForId

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def GetMemberForId(objHere, strMemberId):
    objMembers = GetDataFolder(objHere, 'E3Member')
    strBatchId = strMemberId[8:11]
    try:
        return objMembers.unrestrictedTraverse('Batch%s/%s' % (strBatchId, strMemberId))
    except:
        return None
开发者ID:CoachCoen,项目名称:ECL,代码行数:9,代码来源:E3Members.py

示例3: NewObject

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
    def NewObject(self, objTarget = None, strId = ''):
        if not strId:
            strId = self.NextId()
        if not objTarget:
            objTarget = GetDataFolder(self, self.id)
            if self.Batched:
                strBatchName = 'Batch%s' % str(self.CurrentBatch).zfill(3)
                try:
                    objTarget = objTarget.unrestrictedTraverse(strBatchName)
                except:
                    objTarget = AddFolder(objTarget, strBatchName)
        AddFunction = eval("objTarget.manage_addProduct['%s'].add%s" % (self.Category, self.id))
        AddFunction(strId)
#        print "Created %s in %s with id %s" % (self.id, objTarget.id, strId)
        objObject = objTarget.unrestrictedTraverse(strId)

#        if self.HasCatalogue:
#            objCatalogue = GetDataFolder(self, self.id).Catalogue
#            objCatalogue.catalog_object(objObject)

        return objObject
开发者ID:CoachCoen,项目名称:ECL,代码行数:23,代码来源:clsDataObjectDefinition.py

示例4: TopPostersForWholeYear

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def TopPostersForWholeYear(objHere, intYear):
    objArchive = GetDataFolder(objHere, 'E3Messages')
    dictResult = {}
    for intMonth in range(1, 13):
        try:
            objMonth = objArchive.unrestrictedTraverse('%s/%s-%s' % (intYear, intYear, str(intMonth).zfill(2)))
        except:
            objMonth = None
        if objMonth:
            for objThread in objMonth.objectValues():
                strUserId = objThread.UserId
                strSubject = objThread.mailSubject.lower()
                if "[" in strSubject:
                    strSubject = strSubject[strSubject.find("["):]
                if not dictResult.has_key(strUserId):
                    dictResult[strUserId] = (0, 0)
                (intPlain, intAdv) = dictResult[strUserId]
                if "adv" in strSubject:
                    dictResult[strUserId] = (intPlain, intAdv + 1)
                else:
                    dictResult[strUserId] = (intPlain + 1, intAdv)

    lstResult = []

    for strUserId in dictResult.keys():
        lstResult.append((strUserId, dictResult[strUserId]))

    lstResult.sort(TopPoster)

    strResult = """<h1>Top posters for %s</h1>
    <ol>
    """ % intYear
    intDone = 0
    for (strUserId, (intCount, intAdverts)) in lstResult:
        objMember = GetMemberForId(objHere, strUserId)
        if objMember:
            strName = objMember.VisibleName(True)
            strEmail = objMember.EmailDeliveryAddress
            if objMember.MembershipType == None:
                strStatus = "Expired"
            else:
                strStatus = objMember.MembershipType
        else:
            strName = "unknown"
            strEmail = ""
            strStatus = ""
        strResult += """<li>%s posts (plus %s adverts) by %s (%s, %s, %s)</li>\n""" % (intCount, intAdverts, strName, strUserId, strEmail, strStatus)
        intDone += 1
        if intDone >= 20:
            strResult += "</ol>\n"
            return strResult
    strResult += "</ol>\n"
    return strResult
开发者ID:CoachCoen,项目名称:ECL,代码行数:55,代码来源:E3Admin.py

示例5: TopPostersForMonth

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def TopPostersForMonth(objHere, intYear, intMonth):
    objArchive = GetDataFolder(objHere, 'E3Messages')
    dictResult = {}
    try:
        objMonth = objArchive.unrestrictedTraverse('%s/%s-%s' % (intYear, intYear, str(intMonth).zfill(2)))
    except:
        return ""
    for objThread in objMonth.objectValues():
        strUserId = objThread.UserId
        strSubject = objThread.mailSubject.lower()
        if "[" in strSubject:
            strSubject = strSubject[strSubject.find("["):]
        if not dictResult.has_key(strUserId):
            dictResult[strUserId] = (0, 0)
        (intPlain, intAdv) = dictResult[strUserId]
        if "adv" in strSubject:
            dictResult[strUserId] = (intPlain, intAdv + 1)
        else:
            dictResult[strUserId] = (intPlain + 1, intAdv)
    lstResult = []

    for strUserId in dictResult.keys():
        lstResult.append((strUserId, dictResult[strUserId]))

    lstResult.sort(TopPoster)

    strResult = """<h1>Top posters for %s %s</h1>
    <ol>
    """ % (MonthName(intMonth), intYear)
    intDone = 0
    for (strUserId, (intCount, intAdverts)) in lstResult:
        objMember = GetMemberForId(objHere, strUserId)
        if objMember:
            strName = objMember.VisibleName(True)
        else:
            strName = "unknown"
        strResult += """<li>%s posts (plus %s adverts) by %s (%s)</li>\n""" % (intCount, intAdverts, strName, strUserId)
        intDone += 1
        if intDone >= 10:
            strResult += "</ol>\n"
            return strResult
    strResult += "</ol>\n"
    return strResult
开发者ID:CoachCoen,项目名称:ECL,代码行数:45,代码来源:E3Admin.py

示例6: CountAllMessages

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def CountAllMessages(objHere):
    """Counts number of messages by month/year, stores in E3Messages.MessageCount"""
    dtmNow = datetime.datetime.today()
    objMessages = GetDataFolder(objHere, 'E3Messages')
    lstLines = []
    for intYear in range(dtmNow.year, 1996, -1):
        strLine = str(intYear)
        for intMonth in range(1, 13):
            intCount = 0
            try:
                objMonth = objMessages.unrestrictedTraverse('%s/%s-%s' % (intYear, intYear, str(intMonth).zfill(2)))
            except:
                objMonth = None
            if objMonth:
                for objThread in objMonth.objectValues():
                    intCount = intCount + 1 + len(objThread.objectValues('Folder'))

            strLine = strLine + " " + str(intCount)
        lstLines.append(strLine)
    objMessages.MessageCount = lstLines
开发者ID:CoachCoen,项目名称:ECL,代码行数:22,代码来源:E3Messages.py

示例7: ListRecent

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def ListRecent(objHere, intCount, fnFunction, blnLongFormat = False):
    """Returns most <intCount> most recent messages, either
        - Discussion (not advert, at least 2 sub-messages)
        - Message (not advert, maximum 1 sub-message)
        - Advert
        Either in long format (used within the page contents) or
        in short format (used in side bar)"""
    # Any message which has at least 2 replies
#    if intCount > 3:
#        if not IsLoggedIn(objHere):
#            return "<p>Members only</p>"
#        if not IsFullMember(objHere):
#            return "<p>Current members only</p>"
    lstFound = []
    dtmNow = datetime.datetime.today()
    intMonth = dtmNow.month
    intYear = dtmNow.year
    objMessages = GetDataFolder(objHere, 'E3Messages')
    if not objMessages:
        return "Message folder not found"
    # They might not come out in order, so instead just grab whole month's worth of messages until at least enough, then sort
    if not blnLongFormat:
        blnFullMember = True
    else:
        blnFullMember = IsFullMember(objHere)
    while len(lstFound) < intCount * 3 and intYear > 1996:
        try:
            objMonth = objMessages.unrestrictedTraverse('%s/%s-%s' % (intYear, intYear, str(intMonth).zfill(2)))
        except:
            objMonth = None
#            print "Not found", intYear, intMonth
        if objMonth:
            lstFound = lstFound + fnFunction(objMonth, blnFullMember)
        intMonth = intMonth - 1
        if intMonth == 0:
            intMonth = 12
            intYear = intYear - 1

    dictFound = {}
    for objThread in lstFound:
        dictFound[objThread.mailDate] = objThread

    lstDates = dictFound.keys()

    lstDates.sort(ReverseSort)

    intDone = 0
    if blnLongFormat:
        strResult = u""
    else:
        strResult = u"<ul>\n"

    blnEvenRow = False
    for dtmDate in lstDates:
        objThread = dictFound[dtmDate]
        if intDone < intCount:
            if blnLongFormat:
                strToAdd = FormatOneThread(objThread, blnEvenRow, blnFullMember)
                blnEvenRow = not blnEvenRow
            else:
                strToAdd = ShortFormatMessage(objThread)
            strToAdd = ToUnicode(strToAdd)
            strResult += strToAdd
        intDone = intDone + 1

    if not blnLongFormat:
        strResult = strResult + u"</ul>\n"

    strResult = ToUnicode(strResult)
    return strResult
开发者ID:CoachCoen,项目名称:ECL,代码行数:72,代码来源:E3Messages.py

示例8: GetListForMonth

# 需要导入模块: from libDatabase import GetDataFolder [as 别名]
# 或者: from libDatabase.GetDataFolder import unrestrictedTraverse [as 别名]
def GetListForMonth(objHere, intYear, intMonth, intDate, intOffset, intMaxMessages = 20):
    """Get a list of messages, nicely formatted in row format,
        for the specified intYear/intMonth and optionally intDate"""
    blnFullMember = IsFullMember(objHere)
    strResult = ""
    objArchive = GetDataFolder(objHere, 'E3Messages')
    try:
        objMonth = objArchive.unrestrictedTraverse('%s/%s-%s' % (intYear, intYear, str(intMonth).zfill(2)))
    except:
        return "<p>No messages found for this month</p>"

    dictThreads = {}
    intMessages = 0
    intPublicMessages = 0
    for objThread in objMonth.objectValues():
        if not intDate or objThread.mailDate.day() == intDate:
            intPublicMessages += 1
            if blnFullMember or not objThread.Private:
                dictThreads[objThread.mailDate] = objThread
        for objMessage in objThread.objectValues('Folder'):
            if not intDate or objMessage.mailDate.day() == intDate:
                intPublicMessages += 1
                if blnFullMember or not objMessage.Private:
                    dictThreads[objThread.mailDate] = objMessage

    strURL = '/Archive/ViewMonth'
    intThreads = len(dictThreads)
#    intThreads = len(dictThreads.keys())
    if blnFullMember:
        strPublic = ""
    else:
        strPublic = " public "
    if intThreads == 0:
        return """<p class="Message">No %s messages found</p>""" % strPublic
#    if not intDate:
#        intMessages = MessageCountForMonth(objHere, intYear, intMonth)
    intFirstThread = intOffset + 1
    intLastThread = intOffset + intMaxMessages
    if intLastThread > intThreads:
        intLastThread = intThreads
#    strNavigation = """<p>%(Messages)s message%(MessagesPlural)s found in %(Threads)s thread%(ThreadsPlural)s""" % {'Messages': intMessages,
#            'MessagesPlural': IsPlural(intMessages),
#            'Threads': intThreads,
#            'ThreadsPlural': IsPlural(intThreads)}

    strNavigation = """<p>%(Messages)s %(Public)s message%(MessagesPlural)s found""" % {'Messages': intThreads,
        'MessagesPlural': IsPlural(intThreads),
        'Public': strPublic}

    if intMaxMessages < intThreads:
        strLink = strURL + "?Year=%s&Month=%s" % (intYear, intMonth)
        if intDate:
            strLink = strLink + "&Date=%s" % intDate
        strLink = strLink + "&Offset=%s"

        strNavigation = strNavigation + "<br />" + BuildPagingList(intMaxMessages, intThreads, intFirstThread, intLastThread, strLink, intOffset)

    strNavigation = strNavigation + "</p>"

    lstDates = dictThreads.keys()
    lstDates.sort()

    blnEvenRow = False
    for intI in range(intOffset, intOffset + intMaxMessages + 1):
        if intI < len(lstDates):
            strOneThread = FormatOneThread(dictThreads[lstDates[intI]], blnEvenRow, blnFullMember)
            strOneThread = ToUnicode(strOneThread)
            strResult = strResult + strOneThread
            blnEvenRow = not blnEvenRow

    strResult = strNavigation + strResult + "<p>%s</p>" % strNavigation
    strResult = ToUnicode(strResult)
    return strResult
开发者ID:CoachCoen,项目名称:ECL,代码行数:75,代码来源:E3Messages.py


注:本文中的libDatabase.GetDataFolder.unrestrictedTraverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。