MPvHarmelen / Freevle

A good looking website package for schools, including visual awesomeness & an easy as pie CMS
http://freevle.org
10 stars 4 forks source link

Page slug validation gives error, but only on first run #216

Open MPvHarmelen opened 10 years ago

MPvHarmelen commented 10 years ago

The first time a block of code where a page is created is run, the following exception is raised:

  File "D:\Martin\Documents\GitHub\Freevle\freevle\blueprints\cms\models.py", line 175, in validate_slug
    subcategory = self.subcategory if self.subcategory is not None else Subcategory.query.get(self.subcategory_id)
  File "C:\Program Files\Python 3.3.2\lib\site-packages\sqlalchemy\orm\query.py", line 795, in get
    if len(ident) != len(mapper.primary_key):
TypeError: object of type 'NoneType' has no len()

The second time the block of code is run, no error is raised. I sort of added a workaround by adding a try/except statement, but it's really ugly and probably buggy too.