Example #1
0
 def site(self, name, active_only):
     """
         Create and return a site object that holds each section.
         Options for the add_child function is kept as self.kwargs in each part
     """
     site = Section(name).configure(promote_children=True)
     for part in self.each_part(active_only):
         urls = part.load("urls")
         if urls and hasattr(urls, 'section'):
             site.add_child(urls.section, **part.kwargs)
     return site
Example #2
0
File: parts.py Project: areski/cwf
 def site(self, name, active_only):
     """
         Create and return a site object that holds each section.
         Options for the add_child function is kept as self.kwargs in each part
     """
     site = Section(name).configure(promote_children=True)
     for part in self.each_part(active_only):
         urls = part.load("urls")
         if urls and hasattr(urls, 'section'):
             site.add_child(urls.section, **part.kwargs)
     return site
Example #3
0
equal_to = None

# Function to make a view that returns response
def make_view(response):
    def view(request):
        return HttpResponse(response)
    return view

########################
###   URLS FOR TESTING
########################

    ########################
    ### Normal section

section = Section('base')

# Add with no children
add0 = section.add('add0').configure(target=make_view('/add0/'))

# Add with children, no first
add1 = section.add('add1').configure(target=make_view('/add1/'))
add12 = add1.add('add12').configure(target=make_view('/add1/add12/'))
add123 = add12.add('add123').configure(target=make_view('/add1/add12/add123/'))

# Add with no target and no children
add_nt0 = section.add('add_nt0')

# Add with no target and children
add_nt1 = section.add('add_nt1')
add_nt12 = add_nt1.add('add_nt12').configure(target=make_view('/add_nt1/add_nt12/'))
Example #4
0
import fudge

# Function to make a view that returns response
def make_view(response):
    def view(request, *args, **kwargs):
        res = HttpResponse(response)
        res.section = request.section
        return res
    return view

########################
###   URLS FOR TESTING
########################

section = Section('', name="templatetest")
section.first().configure(alias="Home")

    ########################
    ###   SECTION1

sect1 = section.add('one').configure(target=make_view("/one/"))
sect1_some = sect1.add('some').configure(alias='blah', target=make_view("/one/some/"))
sect1_blah = sect1.add('\w+').configure(
      match = 'blah'
    , target=make_view("/one/<blah>/")
    , values = Values(
        lambda info : ['2', '1', '3']
      , lambda info, value : ('%s_url' % value, 'alias_%s' % value)
      , sorter = True
      )
Example #5
0
# Function to make a view that returns response
def make_view(response):
    def view(request, *args, **kwargs):
        res = HttpResponse(response)
        res.section = request.section
        return res
    return view

########################
###   URLS FOR TESTING
########################

    ########################
    ### Normal section

root = Section('').configure(promote_children=True, namespace='root')

root.add("one").configure(target=make_view("one"))

root.add("two").configure(target=make_view("two"))

three = root.add("three").configure(target=make_view("three"))
three.add("other").configure(target=make_view("three/other"))
three.add("three_child2").configure(target=make_view("three/three_child2"))

four = root.add("four").configure(target=make_view("four"))
four.add("jother").configure(target=make_view("four/other"))

five = root.add("five").configure(target=make_view("five"), promote_children=True)
six = five.add("six").configure(target=make_view("five/six"))
seven = five.add("seven").configure(target=make_view("five/seven"))
Example #6
0
from cwf.sections.section import Section

# Function to make a view that returns response
def make_view(response):
    def view(request):
        return HttpResponse(response)
    return view

########################
###   URLS FOR TESTING
########################

    ########################
    ### Normal section

section = Section('base')

# Add with no children
add0 = section.add('add0').configure(target=make_view('/add0/'))

# Add with children, no first
add1 = section.add('add1').configure(target=make_view('/add1/'))
add12 = add1.add('add12').configure(target=make_view('/add1/add12/'))
add123 = add12.add('add123').configure(target=make_view('/add1/add12/add123/'))

# Add with no target and no children
add_nt0 = section.add('add_nt0')

# Add with no target and children
add_nt1 = section.add('add_nt1')
add_nt12 = add_nt1.add('add_nt12').configure(target=make_view('/add_nt1/add_nt12/'))
Example #7
0
# Function to make a view that returns response
def make_view(response):
    def view(request, *args, **kwargs):
        res = HttpResponse(response)
        res.section = request.section
        return res
    return view

########################
###   URLS FOR TESTING
########################

    ########################
    ### Normal section

root = Section('').configure(promote_children=True, namespace='root')

root.add("one").configure(target=make_view("one"))

root.add("two").configure(target=make_view("two"))

three = root.add("three").configure(target=make_view("three"))
three.add("other").configure(target=make_view("three/other"))
three.add("three_child2").configure(target=make_view("three/three_child2"))

four = root.add("four").configure(target=make_view("four"))
four.add("jother").configure(target=make_view("four/other"))

five = root.add("five").configure(target=make_view("five"), promote_children=True)
six = five.add("six").configure(target=make_view("five/six"))
seven = five.add("seven").configure(target=make_view("five/seven"))