1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@view_config(route_name="cart_add_product")
def cart_add_product(request):

    product_id = request.params.get("product_id", None)

    if product_id is None:
        msg = ("missing product_id.", "error")
        request.session.flash(msg)
        return HTTPFound(get_referer_or_home(request))

    product = get_product_by_id(request.dbsession, product_id)

    if product is None:
        msg = ("invalid product_id.", "error")
        request.session.flash(msg)
        return HTTPFound(get_referer_or_home(request))

    elif product.is_not_ready:
        msg = ("that product is not ready for purchase.", "error")
        request.session.flash(msg)
        return HTTPFound(get_referer_or_home(request))

    elif not request.is_saas_domain and request.shop.uuid_str != product.shop_uuid_str:
        request.session.flash(("Refusing to add a product from another shop to cart.", "error"))
        return HTTPFound("/cart")

    msg = ('You added "{}" to your cart.'.format(product.title), "success")
    request.active_cart.add_product(product)
    request.dbsession.add(request.active_cart)
    request.dbsession.flush()
    request.session.flash(msg)
    return HTTPFound("/cart")



2021-04-15 17:36:41,681 ERROR [waitress:404][waitress-2] Exception while serving /cart/c59e7464-2852-4f80-ad56-0134805375b1
Traceback (most recent call last):
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/waitress/channel.py", line 397, in service
    task.service()
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/waitress/task.py", line 168, in service
    self.execute()
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/waitress/task.py", line 434, in execute
    app_iter = self.channel.server.application(environ, start_response)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid/router.py", line 270, in __call__
    response = self.execution_policy(environ, self)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid_retry/__init__.py", line 127, in retry_policy
    response = router.invoke_request(request)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid/router.py", line 248, in invoke_request
    request._process_response_callbacks(response)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid/request.py", line 85, in _process_response_callbacks
    callback(self, response)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid/session.py", line 258, in set_cookie_callback
    self._set_cookie(response)
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/pyramid/session.py", line 325, in _set_cookie
    serializer.dumps((self.accessed, self.created, dict(self)))
  File "/home/fox/git/make_post_sell/env/lib64/python3.9/site-packages/webob/cookies.py", line 660, in dumps
    sig = hmac.new(self.salted_secret, cstruct, self.digestmod).digest()
  File "/usr/lib64/python3.9/hmac.py", line 170, in new
    return HMAC(key, msg, digestmod)
  File "/usr/lib64/python3.9/hmac.py", line 93, in __init__
    self.update(msg)
  File "/usr/lib64/python3.9/hmac.py", line 113, in update
    self._inner.update(msg)
TypeError: Unicode-objects must be encoded before hashing
^CReceived SIGINT, waiting for server to exit ...
make: *** [Makefile:24: serve] Error 1




# requirements.py3.txt

# Model. 
pyramid_tm
SQLAlchemy
SQLAlchemy-Utils
transaction
zope.sqlalchemy
alembic

# boto3 is needed for AWS s3 or Digital Ocean Spaces.
boto3

# Create URI slugs from titles.
python-slugify

# Future proof, computationally complex password hashes.
bcrypt

# credit card storage and processing.
stripe

# DKIM Signed Email from Python.
dkimpy

# MarkDown is a popular and familair WYSIWYM markup language.
# python 3.
markdown

# my miscutils checked out via git as an editable package.
#-e git+git@github.com:russellballestrini/miscutils.git#egg=miscutils
git+https://github.com/russellballestrini/miscutils.git#egg=miscutils

# human readable timestamps.
ago

# miniuri is a tiny URI parser.
miniuri

# my miscutils package can sanitize and make HTML safe.
# that said, it requires the following:
# Bleach sanitizes MarkDown (removes HTML/Javascript) to prevent XSS.
bleach
bleach-whitelist
beautifulsoup4
html5lib