fixws and 'new' button in grid query
This commit is contained in:
@@ -259,3 +259,5 @@ if __name__=='__main__':
|
||||
test()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class DowCommerce:
|
||||
self.parameters = {}
|
||||
self.setParameter('username', username)
|
||||
self.setParameter('password', password)
|
||||
|
||||
|
||||
|
||||
def process(self):
|
||||
encoded_args = urllib.urlencode(self.parameters)
|
||||
@@ -58,11 +58,11 @@ class DowCommerce:
|
||||
results += str(opened.read()).split(self.delimiter)
|
||||
finally:
|
||||
opened.close()
|
||||
|
||||
|
||||
for result in results:
|
||||
(key,val) = result.split('=')
|
||||
self.results[key] = val
|
||||
|
||||
|
||||
if self.results['response'] == '1':
|
||||
self.error = False
|
||||
self.success = True
|
||||
@@ -74,7 +74,7 @@ class DowCommerce:
|
||||
elif self.results['response'] == '3':
|
||||
self.error = True
|
||||
self.success = False
|
||||
self.declined = False
|
||||
self.declined = False
|
||||
else:
|
||||
self.error = True
|
||||
self.success = False
|
||||
@@ -82,7 +82,7 @@ class DowCommerce:
|
||||
raise DowCommerce.DowCommerceError(self.results)
|
||||
|
||||
def setTransaction(self, creditcard, expiration, total, cvv=None, orderid=None, orderdescription=None,
|
||||
ipaddress=None, tax=None, shipping=None,
|
||||
ipaddress=None, tax=None, shipping=None,
|
||||
firstname=None, lastname=None, company=None, address1=None, address2=None, city=None, state=None, zipcode=None,
|
||||
country=None, phone=None, fax=None, emailaddress=None, website=None,
|
||||
shipping_firstname=None, shipping_lastname=None, shipping_company=None, shipping_address1=None, shipping_address2=None,
|
||||
@@ -93,11 +93,11 @@ class DowCommerce:
|
||||
raise DowCommerce.DowCommerceError('No expiration number passed to setTransaction(): {0}'.format(expiration))
|
||||
if str(total).strip() == '' or total == None:
|
||||
raise DowCommerce.DowCommerceError('No total amount passed to setTransaction(): {0}'.format(total))
|
||||
|
||||
|
||||
self.setParameter('ccnumber', creditcard)
|
||||
self.setParameter('ccexp', expiration)
|
||||
self.setParameter('amount', total)
|
||||
|
||||
|
||||
if cvv:
|
||||
self.setParameter('cvv', cvv)
|
||||
if orderid:
|
||||
@@ -110,10 +110,10 @@ class DowCommerce:
|
||||
self.setParameter('tax', tax)
|
||||
if shipping:
|
||||
self.setParameter('shipping', shipping)
|
||||
|
||||
## billing info
|
||||
|
||||
## billing info
|
||||
if firstname:
|
||||
self.setParameter('firstname', firstname)
|
||||
self.setParameter('firstname', firstname)
|
||||
if lastname:
|
||||
self.setParameter('lastname', lastname)
|
||||
if company:
|
||||
@@ -138,7 +138,7 @@ class DowCommerce:
|
||||
self.setParameter('email', emailaddress)
|
||||
if website:
|
||||
self.setParameter('website', website)
|
||||
|
||||
|
||||
## shipping info
|
||||
if shipping_firstname:
|
||||
self.setParameter('shipping_firstname', shipping_firstname)
|
||||
@@ -147,9 +147,9 @@ class DowCommerce:
|
||||
if shipping_company:
|
||||
self.setParameter('shipping_company', shipping_company)
|
||||
if shipping_address1:
|
||||
self.setParameter('shipping_address1', shipping_address1)
|
||||
self.setParameter('shipping_address1', shipping_address1)
|
||||
if shipping_address2:
|
||||
self.setParameter('shipping_address2', shipping_address2)
|
||||
self.setParameter('shipping_address2', shipping_address2)
|
||||
if shipping_city:
|
||||
self.setParameter('shipping_city', shipping_city)
|
||||
if shipping_state:
|
||||
@@ -188,12 +188,12 @@ class DowCommerce:
|
||||
def getResultResponseShort(self):
|
||||
responses = ['', 'Approved', 'Declined', 'Error']
|
||||
return responses[int(self.results['response'])]
|
||||
|
||||
|
||||
def getFullResponse(self):
|
||||
return self.results
|
||||
|
||||
return self.results
|
||||
|
||||
def getResponseText(self):
|
||||
return self.results['responsetext']
|
||||
return self.results['responsetext']
|
||||
|
||||
def test():
|
||||
import socket
|
||||
@@ -220,7 +220,7 @@ def test():
|
||||
payment.setTransaction(creditcard, expiration, total, cvv=cvv, tax=tax, orderid=orderid, orderdescription='Test Transaction',
|
||||
firstname='John', lastname='Doe', company='Acme', address1='123 Min Street', city='Hometown', state='VA',
|
||||
zipcode='12345', country='US', phone='888-555-1212', emailaddress='john@noemail.local', ipaddress='192.168.1.1')
|
||||
|
||||
|
||||
payment.process()
|
||||
if payment.isApproved():
|
||||
print 'Payment approved!'
|
||||
@@ -240,3 +240,5 @@ if __name__=='__main__':
|
||||
test()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -190,3 +190,5 @@ if __name__ == "__main__":
|
||||
tornado.ioloop.IOLoop.instance().start()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3906,3 +3906,5 @@ def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, refer
|
||||
result['namespaces'] = feedparser.namespacesInUse
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,3 +51,5 @@ class MemcacheClient(Client):
|
||||
key = '%s/%s' % (self.request.application, key)
|
||||
self.delete(key)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -86,3 +86,5 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
|
||||
apiproxy_stub_map.MakeSyncCall = wrapper
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -63,3 +63,5 @@ def pdf_from_html(html):
|
||||
return pyfpdf_from_html(html)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,4 +14,6 @@ def button(merchant_id="123456789012345",
|
||||
button = '<form action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/%s" id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" target="_top">%s<input name="_charset_" type="hidden" value="utf-8"/><input alt="" src="https://checkout.google.com/buttons/buy.gif?merchant_id=%s&w=117&h=48&style=white&variant=text&loc=en_US" type="image"/></form>' % (merchant_id, list_products, merchant_id)
|
||||
return XML(button)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,3 +5,5 @@ __all__ = ['DAL','Field','drivers','gae']
|
||||
from gluon.dal import DAL, Field, Table, Query, Set, Expression, Row, Rows, drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery, SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType, gae
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -906,3 +906,5 @@ if __name__ == '__main__':
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -123,3 +123,5 @@ if __name__ == "__main__":
|
||||
print authenticate(getpass.getuser(), getpass.getpass())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -164,3 +164,5 @@ if __name__ == '__main__':
|
||||
print ell.generate(1000,prefix=None)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@ def RedisCache(*args, **vars):
|
||||
from gluon.contrib.redis import RedisCache
|
||||
cache.redis = RedisCache('localhost:6379',db=None, debug=True)
|
||||
|
||||
cache.redis.stats()
|
||||
|
||||
cache.redis.stats()
|
||||
|
||||
return a dictionary with statistics of Redis server
|
||||
with one additional key ('w2p_keys') showing all keys currently set
|
||||
from web2py with their TTL
|
||||
if debug=True additional tracking is activate and another key is added
|
||||
('w2p_stats') showing total_hits and misses
|
||||
('w2p_stats') showing total_hits and misses
|
||||
"""
|
||||
|
||||
|
||||
locker.acquire()
|
||||
try:
|
||||
if not hasattr(RedisCache, 'redis_instance'):
|
||||
@@ -52,7 +52,7 @@ class RedisClient(object):
|
||||
app = request.application
|
||||
else:
|
||||
app = ''
|
||||
|
||||
|
||||
if not app in self.meta_storage:
|
||||
self.storage = self.meta_storage[app] = {
|
||||
CacheAbstract.cache_stats_name: {
|
||||
@@ -72,7 +72,7 @@ class RedisClient(object):
|
||||
obj = self.r_server.get(key)
|
||||
if obj:
|
||||
if self.debug:
|
||||
self.r_server.incr('web2py_cache_statistics:hit_total')
|
||||
self.r_server.incr('web2py_cache_statistics:hit_total')
|
||||
value = pickle.loads(obj)
|
||||
elif f is None:
|
||||
if obj: self.r_server.delete(key)
|
||||
@@ -94,7 +94,7 @@ class RedisClient(object):
|
||||
|
||||
def clear(self, regex):
|
||||
"""
|
||||
Auxiliary function called by `clear` to search and
|
||||
Auxiliary function called by `clear` to search and
|
||||
clear cache entries
|
||||
"""
|
||||
r = re.compile(regex)
|
||||
@@ -120,7 +120,9 @@ class RedisClient(object):
|
||||
statscollector['w2p_keys']["%s_expire_in_sec" % (a)] = \
|
||||
self.r_server.ttl(a)
|
||||
return statscollector
|
||||
|
||||
|
||||
def __keyFormat__(self, key):
|
||||
return 'w2p:%s:%s' % (self.request.application,
|
||||
return 'w2p:%s:%s' % (self.request.application,
|
||||
key.replace(' ', '_'))
|
||||
|
||||
|
||||
|
||||
@@ -588,3 +588,5 @@ if __name__ == '__main__':
|
||||
print test()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -266,3 +266,5 @@ if __name__=='__main__':
|
||||
while True: print run(history, raw_input('>>> ')).rstrip()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from cStringIO import StringIO
|
||||
import random
|
||||
import sys
|
||||
try:
|
||||
import gluon.contrib.simplejson as json # try web2py json serializer
|
||||
import gluon.contrib.simplejson as json # try web2py json serializer
|
||||
except ImportError:
|
||||
try:
|
||||
import json # try stdlib (py2.6)
|
||||
@@ -40,7 +40,7 @@ class JSONRPCError(RuntimeError):
|
||||
def __unicode__(self):
|
||||
return u"%s: %s" % (self.code, self.message)
|
||||
def __str__(self):
|
||||
return self.__unicode__().encode("ascii","ignore")
|
||||
return self.__unicode__().encode("ascii","ignore")
|
||||
|
||||
|
||||
class JSONDummyParser:
|
||||
@@ -55,11 +55,11 @@ class JSONDummyParser:
|
||||
|
||||
class JSONTransportMixin:
|
||||
"json wrapper for xmlrpclib transport interfase"
|
||||
|
||||
|
||||
def send_content(self, connection, request_body):
|
||||
connection.putheader("Content-Type", "application/json")
|
||||
connection.putheader("Content-Length", str(len(request_body)))
|
||||
connection.endheaders()
|
||||
connection.endheaders()
|
||||
if request_body:
|
||||
connection.send(request_body)
|
||||
# todo: add gzip compression
|
||||
@@ -76,7 +76,7 @@ class JSONTransport(JSONTransportMixin, Transport):
|
||||
class JSONSafeTransport(JSONTransportMixin, SafeTransport):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class ServerProxy(object):
|
||||
"JSON RPC Simple Client Service Proxy"
|
||||
|
||||
@@ -99,12 +99,12 @@ class ServerProxy(object):
|
||||
transport = JSONTransport()
|
||||
self.__transport = transport
|
||||
self.__encoding = encoding
|
||||
self.__verbose = verbose
|
||||
self.__verbose = verbose
|
||||
|
||||
def __getattr__(self, attr):
|
||||
"pseudo method that can be called"
|
||||
return lambda *args: self.call(attr, *args)
|
||||
|
||||
|
||||
def call(self, method, *args):
|
||||
"JSON RPC communication (method invocation)"
|
||||
|
||||
@@ -120,15 +120,15 @@ class ServerProxy(object):
|
||||
request,
|
||||
verbose=self.__verbose
|
||||
)
|
||||
|
||||
|
||||
# store plain request and response for further debugging
|
||||
self.json_request = request
|
||||
self.json_response = response
|
||||
|
||||
# parse json data coming from service
|
||||
# parse json data coming from service
|
||||
# {'version': '1.1', 'id': id, 'result': result, 'error': None}
|
||||
response = json.loads(response)
|
||||
|
||||
|
||||
if response['id'] != request_id:
|
||||
raise JSONRPCError(0, "JSON Request ID != Response ID")
|
||||
|
||||
@@ -145,3 +145,5 @@ if __name__ == "__main__":
|
||||
client = ServerProxy(location, verbose='--verbose' in sys.argv,)
|
||||
print client.add(1, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -112,3 +112,5 @@ def sms_email(number,provider):
|
||||
return number+SMSCODES[provider]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -262,3 +262,5 @@ if __name__ == '__main__':
|
||||
print s['c'].computed_value
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Stripe:
|
||||
print Stripe(key).check(d['id'])
|
||||
print Stripe(key).refund(d['id'])
|
||||
Sample output (python dict):
|
||||
{u'fee': 0, u'description': u'test charge', u'created': 1321242072, u'refunded': False, u'livemode': False, u'object': u'charge', u'currency': u'usd', u'amount': 100, u'paid': True, u'id': u'ch_sdjasgfga83asf', u'card': {u'exp_month': 5, u'country': u'US', u'object': u'card', u'last4': u'4242', u'exp_year': 2012, u'type': u'Visa'}}
|
||||
{u'fee': 0, u'description': u'test charge', u'created': 1321242072, u'refunded': False, u'livemode': False, u'object': u'charge', u'currency': u'usd', u'amount': 100, u'paid': True, u'id': u'ch_sdjasgfga83asf', u'card': {u'exp_month': 5, u'country': u'US', u'object': u'card', u'last4': u'4242', u'exp_year': 2012, u'type': u'Visa'}}
|
||||
|
||||
if paid is True than transaction was processed
|
||||
"""
|
||||
@@ -27,11 +27,11 @@ class Stripe:
|
||||
def charge(self,
|
||||
amount,
|
||||
currency='usd',
|
||||
card_number='4242424242424242',
|
||||
card_number='4242424242424242',
|
||||
card_exp_month='5',
|
||||
card_exp_year='2012',
|
||||
card_cvc_check='123',
|
||||
description='test charge'):
|
||||
description='test charge'):
|
||||
params = urllib.urlencode({'amount':amount,
|
||||
'currency':currency,
|
||||
'card[number]':card_number,
|
||||
@@ -62,3 +62,5 @@ if __name__=='__main__':
|
||||
print 'paid',s['paid'],s['amount'] ,s['currency']
|
||||
s = Stripe(key).refund(d[u'id'])
|
||||
print 'refunded',s['refunded']
|
||||
|
||||
|
||||
|
||||
@@ -243,3 +243,5 @@ class TaskBarIcon:
|
||||
STOPPED = 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Aim is
|
||||
Taken from http://pypi.python.org/pypi/httpagentparser (MIT license)
|
||||
Modified my Ross Peoples for web2py to better support iPhone and iPad.
|
||||
Modified by Angelo Compagnucci <angelo.compagnucci@gmail.com> to better support a wide ringe of mobile devices.
|
||||
Now it supports: tablet device (is_tablet), BlackBerry, BlackBerry PlayBook, Android Tablets, Windows Mobile,
|
||||
Now it supports: tablet device (is_tablet), BlackBerry, BlackBerry PlayBook, Android Tablets, Windows Mobile,
|
||||
Symbian.
|
||||
"""
|
||||
import sys
|
||||
@@ -81,11 +81,11 @@ class DetectorBase(object):
|
||||
result['is_mobile'] = is_mobile
|
||||
if is_tablet:
|
||||
result['is_tablet'] = is_tablet
|
||||
|
||||
|
||||
version = self.getVersion(agent)
|
||||
if version:
|
||||
result[self.info_type]['version'] = version
|
||||
|
||||
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -222,13 +222,13 @@ class BlackBerry(OS):
|
||||
look_for = ['BlackBerry']
|
||||
prefs = dict( flavor=['PlayBook'])
|
||||
is_mobile = True
|
||||
|
||||
|
||||
# Manual check for tablet
|
||||
def checkWords(self, agent):
|
||||
if 'BlackBerry' in agent or 'PlayBook' in agent:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def getVersion(self, agent):
|
||||
pass
|
||||
|
||||
@@ -236,14 +236,14 @@ class PlayBook(Flavor):
|
||||
look_for = ['PlayBook']
|
||||
is_mobile=True
|
||||
is_tablet=True
|
||||
|
||||
|
||||
def getVersion(self, agent):
|
||||
return agent.partition('Tablet OS')[2].partition(';')[0].strip()
|
||||
|
||||
class Macintosh(OS):
|
||||
look_for = ['Macintosh']
|
||||
prefs = dict(dist=None, flavor=['MacOS'])
|
||||
|
||||
|
||||
def getVersion(self, agent):
|
||||
pass
|
||||
|
||||
@@ -269,7 +269,7 @@ class Windows(OS):
|
||||
|
||||
def getVersion(self, agent):
|
||||
v = agent.partition('NT')
|
||||
return v[1]+' '+v[2].replace(')',';').partition(';')[0].strip()
|
||||
return v[1]+' '+v[2].replace(')',';').partition(';')[0].strip()
|
||||
|
||||
class WindowsMobile(Dist):
|
||||
name = 'Phone'
|
||||
@@ -320,7 +320,7 @@ class SymbianOS(OS):
|
||||
class Series(Flavor):
|
||||
look_for = ['SymbianOS', 'Series']
|
||||
version_splitters = ['/', ';']
|
||||
|
||||
|
||||
def getVersion(self, agent):
|
||||
return agent.partition('Series')[2].partition(' ')[0].replace('/',' ')
|
||||
|
||||
@@ -330,8 +330,8 @@ class BrowserNG(Browser):
|
||||
|
||||
class iPhone(Dist):
|
||||
look_for = ['iPhone']
|
||||
is_mobile = True
|
||||
prefs = dict(browser=['SafariMobile'])
|
||||
is_mobile = True
|
||||
prefs = dict(browser=['SafariMobile'])
|
||||
|
||||
def getVersion(self, agent):
|
||||
version_end_chars = ['like', ';', ')']
|
||||
@@ -377,7 +377,7 @@ def detect(agent):
|
||||
prefs = detector.prefs
|
||||
break
|
||||
except Exception, ex:
|
||||
result['exception'] = ex
|
||||
result['exception'] = ex
|
||||
return result
|
||||
|
||||
|
||||
@@ -415,8 +415,8 @@ if __name__ == '__main__':
|
||||
import unittest
|
||||
|
||||
data = (
|
||||
|
||||
|
||||
|
||||
|
||||
('Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 Nokia6120c/3.83; Profile/MIDP-2.0 Configuration/CLDC-1.1) AppleWebKit/413 (KHTML, like Gecko) Safari/413',
|
||||
('Series SymbianOS 60 3.1', 'Safari', True),
|
||||
{'is_mobile': True, 'is_tablet': False, 'flavor': {'name': 'Series', 'version': '60 3.1'}, 'os': {'name': 'SymbianOS', 'version': '9.2'}, 'browser': {'name': 'Safari'}},),
|
||||
@@ -503,16 +503,18 @@ if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
class mobilize(object):
|
||||
class mobilize(object):
|
||||
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
||||
def __call__(self):
|
||||
from gluon import current
|
||||
from gluon import current
|
||||
user_agent = current.request.user_agent()
|
||||
if user_agent.is_mobile:
|
||||
if user_agent.is_mobile:
|
||||
items = current.response.view.split('.')
|
||||
items.insert(-1,'mobile')
|
||||
current.response.view = '.'.join(items)
|
||||
return self.func()
|
||||
return self.func()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user