Ñò ,¦{Ic@sádZddkZddkZddkZddklZd„Zd„Zd„Zd„Z d„Z d e fd „ƒYZ d „Z d „Zdd „Zdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(sÛUtility functions for use in templates / controllers *PLEASE NOTE*: Many of these functions expect an initialized RequestConfig object. This is expected to have been initialized for EACH REQUEST by the web framework. iÿÿÿÿN(trequest_configc Cs®|i}xA|iƒD]3\}}t|tƒo|i|ƒ||s2 # cCsy|oVt|tƒo|i|ƒ}qit|tƒo |}qit|ƒi|ƒ}n t|ƒ}ti|dƒS(s+A Unicode handling version of urllib.quote.R(RRR R&turllibtquote(tstringRts((s//usr/lib/python2.6/site-packages/routes/util.pyt _url_quotees  cCsm|oVt|tƒo|i|ƒ}qit|tƒo |}qit|ƒi|ƒ}n t|ƒ}|S(N(RRR R&(R8RR9((s//usr/lib/python2.6/site-packages/routes/util.pyt _str_encodets  c Os|idƒ}|idƒ}|idƒ}|iddƒ}xadddgD]P}|i|ƒo ||=n|i|dƒo|i|dƒ|| '/blog/view/4', url_for(controller='/admin') => '/admin', url_for(controller='admin') => '/admin/view/2' url_for(action='edit') => '/blog/edit/2', url_for(action='list', id=None) => '/blog/list' **Static and Named Routes** If there is a string present as the first argument, a lookup is done against the named routes table to see if there's any matching routes. The keyword defaults used with static routes will be sent in as GET query arg's if a route matches. If no route by that name is found, the string is assumed to be a raw URL. Should the raw URL begin with ``/`` then appropriate SCRIPT_NAME data will be added if present, otherwise the string will be used as the url with keyword args becoming GET query args. tanchorR2tprotocolt qualifiedt_R"iRRt SCRIPT_NAMEt?s%s=%st&swsgiorg.routing_argst mapper_dictt_anchorR$t _protocolt#R!s://s9url_for can only return a string, got unicode instead: %ss7url_for could not generate URL. Called with args: %s %sN(((R R%RRRtFalseRRR)t _routenamestTrueRthasattrRRRtlistttupletappendR6R7RR tjointgetattrRthardcode_namestdefaultsRtfiltertstaticR RtgenerateR:R2R(R=R&tGenerationException(targsRR<R2R=R>RtconfigtrouteRSRturlt query_argsRtvalueRRCt match_dictRtnewargs((s//usr/lib/python2.6/site-packages/routes/util.pyturl_for‚s¤,       + '            t URLGeneratorcBs)eZdZd„Zd„Zd„ZRS(s,The URL Generator generates URL's It is automatically instantiated by the RoutesMiddleware and put into the ``wsgiorg.routing_args`` tuple accessible as:: url = environ['wsgiorg.routing_args'][0][0] Or via the ``routes.url`` key:: url = environ['routes.url'] The url object may be instantiated outside of a web context for use in testing, however sub_domain support and fully qualified URL's cannot be generated without supplying a dict that must contain the key ``HTTP_HOST``. cCs1||_d|jod|dR?t _use_currentR"iRR@RAs%s=%sRBRRDR$RERFsroutes.cached_hostinfoR!s://s1Can only return a string, got unicode instead: %ss/Could not generate URL. Called with args: %s %sN(%R R%RRRGRRR)RHRIRRRRRKRLRMR6R7RR RNRPRQRRRRRStexternalR RRTR:tcache_hostinfoR(R&RU(R`RVRR<R2R=R>RRXt use_currentRSRRYt more_argsRZRR[RR]thostinfo((s//usr/lib/python2.6/site-packages/routes/util.pyt__call__1s¤    #   + '          cOs|dt||ŽS(s@Generate a route that includes params used on the current request The arguments for this method are identical to ``__call__`` except that arguments set to None will remove existing route matches of the same name from the set of arguments used to construct a URL. Rb(RI(R`RVtkwargs((s//usr/lib/python2.6/site-packages/routes/util.pytcurrent s (t__name__t __module__t__doc__RaRhRj(((s//usr/lib/python2.6/site-packages/routes/util.pyR_s  ocOs%t||Ž}tƒ}|i|ƒS(s@Issues a redirect based on the arguments. Redirect's *should* occur as a "302 Moved" header, however the web framework may utilize a different method. All arguments are passed to url_for to retrieve the appropriate URL, then the resulting URL it sent to the redirect function as the URL. (R^Rtredirect(RVRttargetRW((s//usr/lib/python2.6/site-packages/routes/util.pyt redirect_to¬s  cCs.h}|idƒp,|idƒdjp|idƒdjod|ds     0 '   Žœ  !