the error when i put the request.vars in back is :
Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
Traceback (most recent call last):
File "C:\web2py\gluon\restricted.py", line 223, in restricted
ccode = compile2(code, layer)
File "C:\web2py\gluon\restricted.py", line 206, in compile2
return compile(code.rstrip().replace('\r\n', '\n') + '\n', layer, 'exec')
File "C:\web2py\applications\lgc\views\transaction/invoice_cart.html", line
135
{{pass}}
SyntaxError: non-keyword arg after keyword arg
Error snapshot [image: help]
<https://127.0.0.1/admin/default/ticket/lgc/127.0.0.1.2015-03-21.06-56-16.be8b5e5a-afd6-409c-b3a4-9712012f6633#>
<type 'exceptions.SyntaxError'>(non-keyword arg after keyword arg
(transaction/invoice_cart.html, line 135))
pardon, for my bad cutting the code, my full code are :
*controllers/transaction.py*
selling_price = db.product.selling_price
# invoice_cart
def invoice_cart():
return test_transaction.cart_0(selling_price)
*modules/test_transaction.py*
def cart_0(price):
view = current.request.vars.view
sort = current.request.vars.sort
brand = current.request.vars.brand
search_product = current.request.vars.search_product
if current.request.vars.page:
page = int(current.request.vars.page)
else:
page = 0
items_per_page = 10
limitby = (page * items_per_page, (page + 1) * items_per_page + 1)
if brand:
rows = current.db((current.db.product.brand == brand) &
(current.db.product.quantity > 0) ).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~current.db.product.id)
elif search_product:
rows = current.db((current.db.model.id == current.db.product.model) &
(current.db.product.quantity > 0)
)((current.db.product.serial_no.contains(search_product) ) |
(current.db.product.product_no.contains(search_product) ) |
(current.db.model.name.contains(search_product) )
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~current.db.product.id)
elif sort == 'newest':
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~current.db.product.id)
elif sort == 'a_z':
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = current.db.product.model)
elif sort == 'z_a':
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~current.db.product.model)
elif sort == 'highest_price':
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~price)
elif sort == 'lowest_price':
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = price)
else:
rows = current.db((current.db.product.quantity > 0)
).select(current.db.product.ALL,
limitby = limitby,
cache = (current.cache.ram, 10),
orderby = ~current.db.product.id)
return dict(rows = rows, page = page, items_per_page = items_per_page, view
= view, sort = sort,
brand = brand, search_product = search_product)
*views/transaction/invoice_sidebar.html*
{{=DIV(B(T('Search') ) ) }}
<form method="get" action="{{=URL('invoice_cart') }}" class="form-search">
<div class="input-append">
<input type="text" class="span2 search-query" name="search_product"
value="{{=request.vars.search_product or ''}}">
<button type="submit" class="btn">Search</button>
</div>
</form>
{{=DIV(B(T('Brand') ) ) }}
{{brands = db().select(orderby = db.brand.name, cache = (cache.ram, 10) ) }}
<form>
<select onchange="if (this.value) window.location.href=this.value">
<option value></option>
{{for i, brand in enumerate(brands):}}
<option value={{=URL('invoice_cart', vars=dict(brand = brand.id) )
}}>{{=brand.name}}</option>
{{pass}}
</select>
</form>
*views/transaction/invoice_cart.html*
{{left_sidebar_enabled = True}}
{{block left_sidebar}}
{{include 'transaction/invoice_sidebar.html'}}
{{end}}
{{extend 'layout.html'}}
{{=CENTER(DIV(A(T('Checkout'), _href = URL('invoice_checkout'), _title =
T('Checkout'),
_onclick = "javascript:return confirm('Are you sure you want to
process?')",
_class = 'btn btn-success') ) ) }}
<center>
*{{if page & (len(rows) > items_per_page):}}*
* {{=SPAN(A(I(_class = 'icon-chevron-left'), T('Previous'), _title =
T('Previous Page'), *
* _href = URL(vars = dict(page = [page - 1], request.vars) ) ) ) }}*
* |*
* {{=SPAN(A(T('Next'), I(_class = 'icon-chevron-right'), _title =
T('Next Page'), *
* _href = URL(vars = dict(page = [page + 1], request.vars) ) ) ) }}*
*{{elif page:}}*
* {{=SPAN(A(I(_class = 'icon-chevron-left'), T('Previous'), _title =
T('Previous Page'), *
* _href = URL(vars = dict(page = [page - 1], request.vars) ) ) ) }}*
*{{elif len(rows) > items_per_page:}}*
* {{=SPAN(A(T('Next'), I(_class = 'icon-chevron-right'), _title =
T('Next Page'), *
* _href = URL(vars = dict(page = [page + 1], request.vars) ) ) ) }}*
*{{pass}}*
</center>
<span class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
Sort By
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{{if sort == 'a_z':}}
<li>
{{=A(T('Newest'), _title = T('Newest'),
_href = URL(vars = dict(request.vars, sort = 'newest') ) ) }}
</li>
<li>
{{=A(B(T('A-Z') ), _title = T('A-Z') ) }}
</li>
<li>
{{=A(T('Z-A'), _title = T('Z-A'),
_href = URL(vars = dict(request.vars, sort = 'z_a') ) ) }}
</li>
<li>
{{=A(T('Highest Price'), _title = T('Highest Price'),
_href = URL(vars = dict(request.vars, sort = 'highest_price') ) ) }}
</li>
<li>
{{=A(T('Lowest Price'), _title = T('Lowest Price'),
_href = URL(vars = dict(request.vars, sort = 'lowest_price') ) ) }}
</li>
{{elif sort == 'z_a':}}
<li>
{{=A(T('Newest'), _title = T('Newest'),
_href = URL(vars = dict(request.vars, sort = 'newest') ) ) }}
</li>
<li>
{{=A(T('A-Z'), _title = T('A-Z'),
_href = URL(vars = dict(request.vars, sort = 'a_z') ) ) }}
</li>
<li>
{{=A(B(T('Z-A') ), _title = T('Z-A') ) }}
</li>
<li>
{{=A(T('Highest Price'), _title = T('Highest Price'),
_href = URL(vars = dict(request.vars, sort = 'highest_price') ) ) }}
</li>
<li>
{{=A(T('Lowest Price'), _title = T('Lowest Price'),
_href = URL(vars = dict(request.vars, sort = 'lowest_price') ) ) }}
</li>
{{elif sort == 'highest_price':}}
<li>
{{=A(T('Newest'), _title = T('Newest'),
_href = URL(vars = dict(request.vars, sort = 'newest') ) ) }}
</li>
<li>
{{=A(T('A-Z'), _title = T('A-Z'),
_href = URL(vars = dict(request.vars, sort = 'a_z') ) ) }}
</li>
<li>
{{=A(T('Z-A'), _title = T('Z-A'),
_href = URL(vars = dict(request.vars, sort = 'z_a') ) ) }}
</li>
<li>
{{=A(B(T('Highest Price') ), _title = T('Highest Price') ) }}
</li>
<li>
{{=A(T('Lowest Price'), _title = T('Lowest Price'),
_href = URL(vars = dict(request.vars, sort = 'lowest_price') ) ) }}
</li>
{{elif sort == 'lowest_price':}}
<li>
{{=A(T('Newest'), _title = T('Newest'),
_href = URL(vars = dict(request.vars, sort = 'newest') ) ) }}
</li>
<li>
{{=A(T('A-Z'), _title = T('A-Z'),
_href = URL(vars = dict(request.vars, sort = 'a_z') ) ) }}
</li>
<li>
{{=A(T('Z-A'), _title = T('Z-A'),
_href = URL(vars = dict(request.vars, sort = 'z_a') ) ) }}
</li>
<li>
{{=A(T('Highest Price'), _title = T('Highest Price'),
_href = URL(vars = dict(request.vars, sort = 'highest_price') ) ) }}
</li>
<li>
{{=A(B(T('Lowest Price') ), _title = T('Lowest Price') ) }}
</li>
{{else:}}
<li>
{{=A(B(T('Newest') ), _title = T('Newest') ) }}
</li>
<li>
{{=A(T('A-Z'), _title = T('A-Z'),
_href = URL(vars = dict(request.vars, sort = 'a_z') ) ) }}
</li>
<li>
{{=A(T('Z-A'), _title = T('Z-A'),
_href = URL(vars = dict(request.vars, sort = 'z_a') ) ) }}
</li>
<li>
{{=A(T('Highest Price'), _title = T('Highest Price'),
_href = URL(vars = dict(request.vars, sort = 'highest_price') ) ) }}
</li>
<li>
{{=A(T('Lowest Price'), _title = T('Lowest Price'),
_href = URL(vars = dict(request.vars, sort = 'lowest_price') ) ) }}
</li>
{{pass}}
</ul>
</span>
{{if view == 'list':}}
<div class="btn-group pull-right">
<button class="btn dropdown-toggle" data-toggle="dropdown">
View
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
{{=A(T('Grid'), I(_class = 'icon-th-large'), _title = T('Grid View'),
_href = URL(vars = dict(request.vars, view = 'grid') ) ) }}
</li>
<li>
{{=A(B(T('List') ), I(_class = 'icon-th-list'), _title = T('List View') ) }}
</li>
</ul>
</div>
{{for i, row in enumerate(rows):}}
<div class="well">
<table>
{{if i == items_per_page: break}}
<tr>
<td>
{{=IMG(_src=URL('default', 'download', args=row.image),
_alt=row.model, _width='220', _height='220') }}
</td>
<td>
{{=DIV(row.brand.name) }}
{{=DIV(row.product_no) }}
{{=DIV(row.model.ref_no) }}
{{=DIV(row.model.name) }}
{{=DIV(row.serial_no) }}
{{=DIV(T('Rp. '), format(row.selling_price, ",d") ) }}
{{quantity, price = session.invoice.get(row.id, (0, 0) ) }}
{{=SPAN(quantity, _id="item_%s" % row.id) }}
{{=T('In Order') }}
{{=BR() }}
{{=SPAN(XML(A(I(_class = 'icon-plus'), _class = 'btn btn-info', _title =
'Add Quantity',
target = 'item_%s' % row.id, callback = URL('invoice_callback',
vars = dict(id = row.id, price = row.selling_price, action = 'add') )
).xml().replace(' data-w2p_disable_with="default"', '') ) ) }}
{{=SPAN(XML(A(I(_class = 'icon-minus'), _class = 'btn btn-warning', _title
= 'Substract Quantity',
target = 'item_%s' % row.id, callback = URL('invoice_callback',
vars = dict(id = row.id, price = row.selling_price, action = 'subtract')
) ).xml().replace(' data-w2p_disable_with="default"', '') ) ) }}
</td>
</tr>
</table>
</div>
{{pass}}
{{else:}}
<div class="btn-group pull-right">
<button class="btn dropdown-toggle" data-toggle="dropdown">
View
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
{{=A(B(T('Grid') ), I(_class = 'icon-th-large'), _title = T('Grid View') )
}}
</li>
<li>
{{=A(T('List'), I(_class = 'icon-th-list'), _title = T('List View'),
_href = URL(vars = dict(request.vars, view = 'list') ) ) }}
</li>
</ul>
</div>
<ul class="thumbnails">
{{for i, row in enumerate(rows):}}
{{if i == items_per_page: break}}
<li class="span3 pagination-centered">
<div class="thumbnail">
{{=IMG(_src=URL('default', 'download', args=row.image),
_alt=row.model, _style='height:220px; width:220px;') }}
<div class="caption">
{{=DIV(row.brand.name) }}
{{=DIV(row.product_no) }}
{{=DIV(row.model.ref_no) }}
{{=DIV(row.model.name) }}
{{=DIV(row.serial_no) }}
{{=DIV(T('Rp. '), format(row.selling_price, ",d") ) }}
{{quantity, price = session.invoice.get(row.id, (0, 0) ) }}
{{=SPAN(quantity, _id="item_%s" % row.id) }}
{{=T('In Order') }}
{{=BR() }}
{{=SPAN(XML(A(I(_class = 'icon-plus'), _class = 'btn btn-info', _title =
'Add Quantity',
target = 'item_%s' % row.id, callback = URL('invoice_callback',
vars = dict(id = row.id, price = row.selling_price, action = 'add') )
).xml().replace(' data-w2p_disable_with="default"', '') ) ) }}
{{=SPAN(XML(A(I(_class = 'icon-minus'), _class = 'btn btn-warning', _title
= 'Substract Quantity',
target = 'item_%s' % row.id, callback = URL('invoice_callback',
vars = dict(id = row.id, price = row.selling_price, action = 'subtract')
) ).xml().replace(' data-w2p_disable_with="default"', '') ) ) }}
</div>
</div>
</li>
{{pass}}
</ul>
{{pass}}
{{=HR() }}
<center>
{{if page & (len(rows) > items_per_page):}}
{{=SPAN(A(I(_class = 'icon-chevron-left'), T('Previous'), _title =
T('Previous Page'),
_href = URL(vars = dict(request.vars, page = [page - 1]) ) ) ) }}
|
{{=SPAN(A(T('Next'), I(_class = 'icon-chevron-right'), _title = T('Next
Page'),
_href = URL(vars = dict(request.vars, page = [page + 1]) ) ) ) }}
{{elif page:}}
{{=SPAN(A(I(_class = 'icon-chevron-left'), T('Previous'), _title =
T('Previous Page'),
_href = URL(vars = dict(request.vars, page = [page - 1]) ) ) ) }}
{{elif len(rows) > items_per_page:}}
{{=SPAN(A(T('Next'), I(_class = 'icon-chevron-right'), _title = T('Next
Page'),
_href = URL(vars = dict(request.vars, page = [page + 1]) ) ) ) }}
{{pass}}
</center>
about the vars, i think, i've already request all vars in the modules and
then pass it back in return dict()
is there any mistake in my code about unamed args? how to fix it?
thanks and best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.