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


Python util.joinURL函数代码示例

本文整理汇总了Python中twext.web2.dav.util.joinURL函数的典型用法代码示例。如果您正苦于以下问题:Python joinURL函数的具体用法?Python joinURL怎么用?Python joinURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, parent, record):
        """
        @param parent: the parent of this resource.
        @param record: the L{IDirectoryRecord} that this resource represents.
        """
        super(DirectoryPrincipalResource, self).__init__()

        self.cacheNotifier = self.cacheNotifierFactory(self, cacheHandle="PrincipalToken")

        if self.isCollection():
            slash = "/"
        else:
            slash = ""

        assert record is not None, "Principal must have a directory record"

        self.record = record
        self.parent = parent

        url = joinURL(parent.principalCollectionURL(), self.principalUID()) + slash
        self._url = url

        self._alternate_urls = tuple([
            joinURL(parent.parent.principalCollectionURL(), record.recordType, shortName) + slash for shortName in record.shortNames
        ])
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:25,代码来源:principal.py

示例2: calendar_query

    def calendar_query(self, calendar_uri, query, got_xml, data, no_init):

        if not no_init:
            response = yield self.send(SimpleStoreRequest(self, "MKCALENDAR", calendar_uri, authid="wsanchez"))
            response = IResponse(response)
            if response.code != responsecode.CREATED:
                self.fail("MKCALENDAR failed: %s" % (response.code,))

            if data:
                for filename, icaldata in data.iteritems():
                    request = SimpleStoreRequest(self, "PUT", joinURL(calendar_uri, filename + ".ics"), authid="wsanchez")
                    request.stream = MemoryStream(icaldata)
                    yield self.send(request)
            else:
                # Add holiday events to calendar
                for child in FilePath(self.holidays_dir).children():
                    if os.path.splitext(child.basename())[1] != ".ics":
                        continue
                    request = SimpleStoreRequest(self, "PUT", joinURL(calendar_uri, child.basename()), authid="wsanchez")
                    request.stream = MemoryStream(child.getContent())
                    yield self.send(request)

        request = SimpleStoreRequest(self, "REPORT", calendar_uri, authid="wsanchez")
        request.stream = MemoryStream(query.toxml())
        response = yield self.send(request)

        response = IResponse(response)

        if response.code != responsecode.MULTI_STATUS:
            self.fail("REPORT failed: %s" % (response.code,))

        returnValue(
            (yield davXMLFromStream(response.stream).addCallback(got_xml))
        )
开发者ID:anemitz,项目名称:calendarserver,代码行数:34,代码来源:test_multiget.py

示例3: pickNewDefaultCalendar

    def pickNewDefaultCalendar(self, request):
        """
        First see if "calendar" exists in the calendar home and pick that. Otherwise
        create "calendar" in the calendar home.
        """
        calendarHomeURL = self.parent.url()
        defaultCalendarURL = joinURL(calendarHomeURL, "calendar")
        defaultCalendar = (yield request.locateResource(defaultCalendarURL))
        if defaultCalendar is None or not defaultCalendar.exists():
            getter = iter(self.parent._newStoreCalendarHome.calendars())
            # FIXME: the back-end should re-provision a default calendar here.
            # Really, the dead property shouldn't be necessary, and this should
            # be entirely computed by a back-end method like 'defaultCalendar()'
            try:
                aCalendar = getter.next()
            except StopIteration:
                raise RuntimeError("No calendars at all.")

            defaultCalendarURL = joinURL(calendarHomeURL, aCalendar.name())

        self.writeDeadProperty(
            caldavxml.ScheduleDefaultCalendarURL(
                davxml.HRef(defaultCalendarURL)
            )
        )
        returnValue(caldavxml.ScheduleDefaultCalendarURL(
            davxml.HRef(defaultCalendarURL))
        )
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:28,代码来源:schedule.py

示例4: __init__

    def __init__(self, parent, proxyType):
        """
        @param parent: the parent of this resource.
        @param proxyType: a C{str} containing the name of the resource.
        """
        if self.isCollection():
            slash = "/"
        else:
            slash = ""

        url = joinURL(parent.principalURL(), proxyType) + slash

        super(CalendarUserProxyPrincipalResource, self).__init__()
        DAVResourceWithChildrenMixin.__init__(self)

        self.parent          = parent
        self.proxyType       = proxyType
        self._url            = url

        # FIXME: if this is supposed to be public, it needs a better name:
        self.pcollection     = self.parent.parent.parent

        # Principal UID is parent's GUID plus the proxy type; this we can easily
        # map back to a principal.
        self.uid             = "%s#%s" % (self.parent.principalUID(), proxyType)
        self._alternate_urls = tuple(
            joinURL(url, proxyType) + slash
            for url in parent.alternateURIs()
            if url.startswith("/")
        )
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:30,代码来源:calendaruserproxy.py

示例5: defaultAccessControlList

    def defaultAccessControlList(self):
        myPrincipal = self.principalForRecord()

        aces = (
            # Inheritable DAV:all access for the resource's associated principal.
            davxml.ACE(
                davxml.Principal(davxml.HRef(myPrincipal.principalURL())),
                davxml.Grant(davxml.Privilege(davxml.All())),
                davxml.Protected(),
                TwistedACLInheritable(),
            ),
            # Inheritable CALDAV:read-free-busy access for authenticated users.
            davxml.ACE(
                davxml.Principal(davxml.Authenticated()),
                davxml.Grant(davxml.Privilege(caldavxml.ReadFreeBusy())),
                TwistedACLInheritable(),
            ),
        )

        # Give read access to config.ReadPrincipals
        aces += config.ReadACEs

        # Give all access to config.AdminPrincipals
        aces += config.AdminACEs
        
        if config.EnableProxyPrincipals:
            aces += (
                # DAV:read/DAV:read-current-user-privilege-set access for this principal's calendar-proxy-read users.
                davxml.ACE(
                    davxml.Principal(davxml.HRef(joinURL(myPrincipal.principalURL(), "calendar-proxy-read/"))),
                    davxml.Grant(
                        davxml.Privilege(davxml.Read()),
                        davxml.Privilege(davxml.ReadCurrentUserPrivilegeSet()),
                    ),
                    davxml.Protected(),
                    TwistedACLInheritable(),
                ),
                # DAV:read/DAV:read-current-user-privilege-set/DAV:write access for this principal's calendar-proxy-write users.
                davxml.ACE(
                    davxml.Principal(davxml.HRef(joinURL(myPrincipal.principalURL(), "calendar-proxy-write/"))),
                    davxml.Grant(
                        davxml.Privilege(davxml.Read()),
                        davxml.Privilege(davxml.ReadCurrentUserPrivilegeSet()),
                        davxml.Privilege(davxml.Write()),
                    ),
                    davxml.Protected(),
                    TwistedACLInheritable(),
                ),
            )

        return davxml.ACL(*aces)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:51,代码来源:calendar.py

示例6: _addressBookHomeChildURL

 def _addressBookHomeChildURL(self, name):
     if not hasattr(self, "addressBookHomeURL"):
         if not hasattr(self.record.service, "addressBookHomesCollection"):
             return None
         self.addressBookHomeURL = joinURL(
             self.record.service.addressBookHomesCollection.url(),
             uidsResourceName,
             self.record.uid
         )
     url = self.addressBookHomeURL
     if url is None:
         return None
     else:
         return joinURL(url, name) if name else url
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:principal.py

示例7: readProperty

    def readProperty(self, property, request):
        if type(property) is tuple:
            qname = property
        else:
            qname = property.qname()

        if qname == (caldav_namespace, "calendar-free-busy-set"):
            # Always return at least an empty list
            if not self.hasDeadProperty(property):
                top = self.parent.url()
                values = []
                for cal in self.parent._newStoreCalendarHome.calendars():
                    prop = cal.properties().get(PropertyName.fromString(ScheduleCalendarTransp.sname())) 
                    if prop == ScheduleCalendarTransp(Opaque()):
                        values.append(HRef(joinURL(top, cal.name())))
                returnValue(CalendarFreeBusySet(*values))
        elif qname == (caldav_namespace, "schedule-default-calendar-URL"):
            # Must have a valid default
            try:
                defaultCalendarProperty = self.readDeadProperty(property)
            except HTTPError:
                defaultCalendarProperty = None
            if defaultCalendarProperty and len(defaultCalendarProperty.children) == 1:
                defaultCalendar = str(defaultCalendarProperty.children[0])
                cal = (yield request.locateResource(str(defaultCalendar)))
                if cal is not None and cal.exists() and isCalendarCollectionResource(cal):
                    returnValue(defaultCalendarProperty) 
            
            # Default is not valid - we have to try to pick one
            defaultCalendarProperty = (yield self.pickNewDefaultCalendar(request))
            returnValue(defaultCalendarProperty)
            
        result = (yield super(ScheduleInboxResource, self).readProperty(property, request))
        returnValue(result)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:34,代码来源:schedule.py

示例8: queryCalendarObjectResource

        def queryCalendarObjectResource(resource, uri, name, calendar, timezone, query_ok=False, isowner=True):
            """
            Run a query on the specified calendar.
            @param resource: the L{CalDAVResource} for the calendar.
            @param uri: the uri of the resource.
            @param name: the name of the resource.
            @param calendar: the L{Component} calendar read from the resource.
            """
            
            # Handle private events access restrictions
            if not isowner:
                access = resource.accessMode
            else:
                access = None

            if query_ok or filter.match(calendar, access):
                # Check size of results is within limit
                matchcount[0] += 1
                if max_number_of_results[0] is not None and matchcount[0] > max_number_of_results[0]:
                    raise NumberOfMatchesWithinLimits(max_number_of_results[0])

                if name:
                    href = davxml.HRef.fromString(joinURL(uri, name))
                else:
                    href = davxml.HRef.fromString(uri)
            
                try:
                    yield report_common.responseForHref(request, responses, href, resource, propertiesForResource, props, isowner, calendar=calendar, timezone=timezone)
                except ConcurrentModification:
                    # This can happen because of a race-condition between the
                    # time we determine which resources exist and the deletion
                    # of one of these resources in another request.  In this
                    # case, we ignore the now missing resource rather
                    # than raise an error for the entire report.
                    log.err("Missing resource during query: %s" % (href,))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:35,代码来源:report_calendar_query.py

示例9: _acceptShare

    def _acceptShare(self, request, sharetype, hostUrl, shareUID, displayname=None):

        # Add or update in DB
        oldShare = self.sharesDB().recordForShareUID(shareUID)
        if not oldShare:
            oldShare = share = SharedCollectionRecord(shareUID, sharetype, hostUrl, str(uuid4()), displayname)
            self.sharesDB().addOrUpdateRecord(share)
        
        # Set per-user displayname to whatever was given
        sharedCollection = (yield request.locateResource(hostUrl))
        ownerPrincipal = (yield self.ownerPrincipal(request))
        sharedCollection.setVirtualShare(ownerPrincipal, oldShare)
        if displayname:
            yield sharedCollection.writeProperty(davxml.DisplayName.fromString(displayname), request)
            
        # Calendars always start out transparent
        if sharedCollection.isCalendarCollection():
            yield sharedCollection.writeProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Transparent()), request)
 
        # Return the URL of the shared collection
        returnValue(XMLResponse(
            code = responsecode.OK,
            element = customxml.SharedAs(
                davxml.HRef.fromString(joinURL(self.url(), oldShare.localname))
            )
        ))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:26,代码来源:sharing.py

示例10: queryAddressBookObjectResource

        def queryAddressBookObjectResource(resource, uri, name, vcard, query_ok=False):
            """
            Run a query on the specified vcard.
            @param resource: the L{CalDAVResource} for the vcard.
            @param uri: the uri of the resource.
            @param name: the name of the resource.
            @param vcard: the L{Component} vcard read from the resource.
            """

            if query_ok or filter.match(vcard):
                # Check size of results is within limit
                checkMaxResults()

                if name:
                    href = davxml.HRef.fromString(joinURL(uri, name))
                else:
                    href = davxml.HRef.fromString(uri)

                try:
                    yield report_common.responseForHref(request, responses, href, resource, propertiesForResource, query, vcard=vcard)
                except ConcurrentModification:
                    # This can happen because of a race-condition between the
                    # time we determine which resources exist and the deletion
                    # of one of these resources in another request.  In this
                    # case, we ignore the now missing resource rather
                    # than raise an error for the entire report.
                    log.error("Missing resource during sync: %s" % (href,))
开发者ID:anemitz,项目名称:calendarserver,代码行数:27,代码来源:report_addressbook_query.py

示例11: accessControlList

    def accessControlList(self, request, *args, **kwargs):
        """
        Override this to give write proxies DAV:write-acl privilege so they can add attachments too.
        """

        acl = (yield super(DropBoxHomeResource, self).accessControlList(request, *args, **kwargs))
        
        if config.EnableProxyPrincipals:
            owner = (yield self.ownerPrincipal(request))

            newaces = tuple(acl.children)
            newaces += (
                # DAV:write-acl access for this principal's calendar-proxy-write users.
                davxml.ACE(
                    davxml.Principal(davxml.HRef(joinURL(owner.principalURL(), "calendar-proxy-write/"))),
                    davxml.Grant(
                        davxml.Privilege(davxml.WriteACL()),
                    ),
                    davxml.Protected(),
                    TwistedACLInheritable(),
                ),
            )

            returnValue(davxml.ACL(*newaces))
        
        else:
            returnValue(acl)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:27,代码来源:dropbox.py

示例12: queryCalendarObjectResource

        def queryCalendarObjectResource(resource, uri, name, calendar, timezone, query_ok=False, isowner=True):
            """
            Run a query on the specified calendar.
            @param resource: the L{CalDAVResource} for the calendar.
            @param uri: the uri of the resource.
            @param name: the name of the resource.
            @param calendar: the L{Component} calendar read from the resource.
            """
            
            # Handle private events access restrictions
            if not isowner:
                try:
                    access = resource.readDeadProperty(TwistedCalendarAccessProperty)
                except HTTPError:
                    access = None
            else:
                access = None

            if query_ok or filter.match(calendar, access):
                # Check size of results is within limit
                matchcount[0] += 1
                if max_number_of_results[0] is not None and matchcount[0] > max_number_of_results[0]:
                    raise NumberOfMatchesWithinLimits(max_number_of_results[0])

                if name:
                    href = davxml.HRef.fromString(joinURL(uri, name))
                else:
                    href = davxml.HRef.fromString(uri)
            
                return report_common.responseForHref(request, responses, href, resource, propertiesForResource, props, isowner, calendar=calendar, timezone=timezone)
            else:
                return succeed(None)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:report_calendar_query.py

示例13: readProperty

    def readProperty(self, property, request):
        if type(property) is tuple:
            qname = property
        else:
            qname = property.qname()

        if qname == caldavxml.CalendarFreeBusySet.qname():
            # Synthesize value for calendar transparency state
            top = self.parent.url()
            values = []
            for cal in (yield self.parent._newStoreHome.calendars()):
                if cal.isUsedForFreeBusy():
                    values.append(HRef(joinURL(top, cal.name()) + "/"))
            returnValue(CalendarFreeBusySet(*values))

        elif qname == customxml.CalendarAvailability.qname():
            availability = self.parent._newStoreHome.getAvailability()
            returnValue(customxml.CalendarAvailability.fromString(str(availability)) if availability else None)

        elif qname in (caldavxml.ScheduleDefaultCalendarURL.qname(), customxml.ScheduleDefaultTasksURL.qname()):
            result = (yield self.readDefaultCalendarProperty(request, qname))
            returnValue(result)

        result = (yield super(ScheduleInboxResource, self).readProperty(property, request))
        returnValue(result)
开发者ID:anemitz,项目名称:calendarserver,代码行数:25,代码来源:resource.py

示例14: cleanup

 def cleanup(self):
     """
     Do some cleanup after the real request.
     """
     # Remove created resources
     href = joinURL(self.sessions[0].calendarHref, "put.ics")
     self.sessions[0].deleteResource(URL(path=href))
开发者ID:anemitz,项目名称:calendarserver,代码行数:7,代码来源:put.py

示例15: pickNewDefaultCalendar

    def pickNewDefaultCalendar(self, request, tasks=False):
        """
        First see if default provisioned calendar exists in the calendar home and pick that. Otherwise
        pick another from the calendar home.
        """

        componentType = "VTODO" if tasks else "VEVENT"
        test_name = "tasks" if tasks else "calendar"
        prop_to_set = customxml.ScheduleDefaultTasksURL if tasks else caldavxml.ScheduleDefaultCalendarURL

        calendarHomeURL = self.parent.url()
        defaultCalendarURL = joinURL(calendarHomeURL, test_name)
        defaultCalendar = (yield request.locateResource(defaultCalendarURL))
        if defaultCalendar is None or not defaultCalendar.exists():
            # Really, the dead property shouldn't be necessary, and this should
            # be entirely computed by a back-end method like 'defaultCalendar()'

            @inlineCallbacks
            def _findDefault():
                for calendarName in (yield self.parent._newStoreHome.listCalendars()):  # These are only unshared children
                    if calendarName == "inbox":
                        continue
                    calendar = (yield self.parent._newStoreHome.calendarWithName(calendarName))
                    if not calendar.owned():
                        continue
                    if not calendar.isSupportedComponent(componentType):
                        continue
                    break
                else:
                    calendarName = None
                returnValue(calendarName)

            foundName = yield _findDefault()
            if foundName is None:
                # Create a default and try and get its name again
                yield self.parent._newStoreHome.ensureDefaultCalendarsExist()
                foundName = yield _findDefault()
                if foundName is None:
                    # Failed to even create a default - bad news...
                    raise RuntimeError("No valid calendars to use as a default %s calendar." % (componentType,))

            defaultCalendarURL = joinURL(calendarHomeURL, foundName)

        prop = prop_to_set(davxml.HRef(defaultCalendarURL))
        self.writeDeadProperty(prop)
        returnValue(prop)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:46,代码来源:resource.py


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