Wq-db

Latest version: v1.0.0.post1

Safety actively analyzes 621892 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 5

1.0.01

Post-release of [wq.db 1.0](https://github.com/wq/wq.db/releases/v1.0.0-1) to document the temporary lack of support for Django 2.0 (71 via tomaszn). See 72 for followup.

1.0

Enhancements
- Updates to support Django REST Framework 3 and Django 1.8 (32, 34, 36)
- Improved [patterns](https://wq.io/docs/about-patterns) with support for the [HTML JSON forms](http://www.w3.org/TR/html-json-forms/) field naming convention for submitting "child"/"attachment" records together with a parent object (33). The "classic" form syntax is still supported but will be dropped in wq.db 1.0. To facilitate rendering lists of attachments in edit views, an array `index` attribute (inspired by Handlebars) has been added to the Mustache template context.
- Added `{{wq_config}}` and `{{page_config}}` to the `wq.db.rest.context_processors`, for better compatibility with [wq/app.js](https://wq.io/docs/app-js) (25).
- Include a serialization of the referenced `content_object` in serializers for attachment models in `patterns` (7).
- Throw a configuration error if a model is registered with the same name or url as an existing model (21).
- Ensure that patterns models aren't added to content types if they aren't used (14).
- Significantly increased test coverage.
- Various minor bug fixes.

Breaking Changes
1. The model registration API in `wq.db.rest.app` has been moved to `wq.db.rest`. This makes the API even more similar to Django's `admin`, and also eliminates the already overloaded use of "app" as an identifier.
As part of this change, `wq.db.rest.settings` has been moved to `wq.db.default_settings`. For examples, see item 1 in the upgrade notes below.
2. The `patterns` convenience modules (e.g. `wq.db.patterns.models`, `wq.db.patterns.admin`, and the new `wq.db.patterns.serializers`) no longer import everything from the corresponding Django or DRF namespaces. This makes it clearer where various classes are coming from. For examples, see item 2 in upgrade notes below.
3. Dropped compatibility with Django 1.6 (31) and Django REST Framework 2.X. wq.db 0.8.0 and later **will not work** with these versions. All compatibility hacks for Django 1.6 have been removed, as has support for South, now that migrations are built in to Django 1.7 and higher.
4. The default `ModelSerializer` class no longer attempts to automatically create certain one-to-many nested serializers, e.g. the `annotations` attribute on serializers for `AnnotatedModel` subclasses (22). This "magic" behavior proved to be confusing and hard to override. Instead, models extending `AnnotatedModel` or other patterns should be registered with custom serializers, e.g. `AnnotatedModelSerializer`. For an example, see Item 2 in the upgrade notes below. Custom nested serializers can be added using the standard Django REST Framework serializer syntax.
5. Since it's now much easier to create custom patterns and nested serializers, the [annotate](https://wq.io/docs/annotate) pattern is no longer swappable (see 6) and no longer includes a `contenttype` property on `AnnotationType`.
6. Previous versions of the `ModelSerializer` would serialize foreign keys as `[fieldname]_id`, but expect form submissions to use `[fieldname]` (without the `_id` suffix). Needless to say, this inconsistency was confusing to work with. In wq.db 0.8.0, foreign keys are both sent and recieved with the `_id` suffix (11). For an example, see item 4 in the upgrade notes below. As before, the `[fieldname]` without the suffix can be used in detail templates to retrieve properties from the referenced object.
7. The JSONP-based AMD serializer has been removed. This was primarily there to make it possible to load the [wq configuration object](https://wq.io/docs/config) via `config.js`. This file can be generated from the command line via `./manage.py dump_config`.
8. The `{{csrftoken}}` context variable has been removed in favor of Django's built-in `{{csrf_token}}`.

Upgrade Notes

If you are starting with a new project, you shouldn't need to worry about anything in this section. If you have an existing project, you will want to take the following steps:
1. Update all references to `wq.db.rest.app` (e.g. in your `*/rest.py` and your `urls.py`), and references to `wq.db.rest.settings` (e.g. in your `settings.py`).
**`*/rest.py`**

python
Old
from wq.db.rest import app
from .models import MyModel

app.router.register_model(MyModel)

New
from wq.db import rest
from .models import MyModel

rest.router.register_model(MyModel)


**`urls.py`**

python
Old
from wq.db.rest import app
app.autodiscover()
urlpatterns = patterns('',
url(r'^', include(app.router.urls))
)

New
from wq.db import rest
rest.autodiscover()
urlpatterns = patterns('',
url(r'^', include(rest.router.urls))
)


**`settings.py`**

python
Old
from wq.db.rest.settings import (
TEMPLATE_LOADERS,
TEMPLATE_CONTEXT_PROCESSORS,
...

New
from wq.db.default_settings import (
TEMPLATE_LOADERS,
TEMPLATE_CONTEXT_PROCESSORS,
...

2. If you are using any of the [patterns](https://wq.io/docs/about-patterns) modules, check all of your `models.py` and be sure you explicitly import `django.db.models`.

python
Old
from wq.db.patterns import models

class MyModel(models.IdentifiedModel):
name = models.CharField(max_length=255)

New
from django.db import models
from wq.db.patterns import models as patterns

class MyModel(patterns.IdentifiedModel):
name = models.CharField(max_length=255)


You will also want to update how you register patterns model subclasses with the rest API:

python
Old
from wq.db.rest import app
from .models import MyModel

app.router.register_model(MyModel)

New
from wq.db import rest
from wq.db.patterns import rest as patterns
from .models import MyModel

rest.router.register_model(
MyModel, serializer=patterns.IdentifiedModelSerializer
)

3. If you are using your own serializer classes, read the [Django REST Framework 3.0](http://www.django-rest-framework.org/topics/3.0-announcement/) release notes and make any necessary changes. In particular, note the new use of `ListSerializer` classes and the renamed `to_representation`/`to_internal_value` methods.
4. Update your "edit" templates to use `[fieldname]_id` when referencing foreign keys.

xml
<!-- Old -->
<input type="hidden" name="type" value="{{type_id}}">
<select name="species">
{{species_list}}
<option value="{{id}}">{{label}}</option>
{{/species_list}}
</select>
<!-- New -->
<input type="hidden" name="type_id" value="{{type_id}}">
<select name="species_id">
{{species_list}}
<option value="{{id}}">{{label}}</option>
{{/species_list}}
</select>


Also, update your `partials/csrf.html` to use the new context variable name

xml
<!-- Old -->
<input type="hidden" name="csrfmiddlewaretoken" value="{{csrftoken}}">
<!-- New -->
<input type="hidden" name="csrfmiddlewaretoken" value="{{csrf_token}}">


If you are using one or more [patterns](https://wq.io/docs/about-patterns), you may also want to take advantage of the new `<input>` naming convention. This will be required as of wq.db 1.0, but both styles are supported for the time being. See the documentation for the individual [patterns](https://wq.io/docs/about-patterns) modules for more information.

1.0.0

**wq.db 1.0.0** is finally here! This is the first stable release of wq.db 1.0, which is now ready for production use.

Changes since wq.db 1.0.0 RC1
* Standardize and fix the results of various `type_filter` settings with [EAV serializers](https://wq.io/docs/eav-vs-relational). Thanks to davidoj for help with this update (64, 65, 66, 67)
* Fix typo in `ModelViewSet` (68 via tomaszn)
* Various improvements to [identify pattern](https://wq.io/docs/identify) (2863130)
* Support for `HEAD` on more views (d51c504)
* Don't override declared label fields (42)
* Incorporate [Code of Conduct](https://github.com/wq/wq.db/blob/master/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/wq/wq.db/blob/master/CONTRIBUTING.md)

1.0.0rc1

**wq.db 1.0.0 RC1** brings a number of enhancements to improve integration with wq.start and wq.app.

wq 1.0 enhancements
* New API to more directly configure the relationship between pagination and offline caching in wq.app (wq/wq.app47, 663bbda). See [Pagination and Caching](https://wq.io/docs/pagination-and-caching) for more information.
* Added support for pre-generating blank nested forms for attachments, which wq.app has supported for some time (61).
* Improved the `form` sections of the generated [wq config object](https://wq.io/docs/config) to better match the output of [xlsconv](https://github.com/wq/xlsconv). The goal is to ensure that [wq.start](https://wq.io/wq.start)'s `wq addform` and `wq maketemplates` commands produce identical template output. (237c07a, 7253f33, 4735982, e3dec4b)

Bug Fixes
* Support fields with `blank=True` and `null=False` (58)
* Avoid 500 errors when performing field and nested configuration lookups (19e918a, 6df5f44, 60)
* Third party compatibility fixes (1ba0360, ae9fd6a, 388336d, b6ee2ac)

1.0.0b3

**wq.db 1.0 beta 3** brings a couple of new features as well as minor bug fixes.

API Change

Django REST Framework 3.5 enforces the [requirement](http://www.django-rest-framework.org/topics/3.5-announcement/modelserializer-fields-and-exclude) that all ModelSerializers have an explicit `fields` or `exclude` attribute. This is supported in wq.db with a new "fields" argument to `router.register_model`. As in DRF, you can request the old behavior of including all fields by specifying `"__all__"` as the argument:

python
from wq.db import rest
from .models import MyModel

rest.router.register_model(
MyModel,
fields="__all__",
)


New Configuration Options
- To facilitate the generation of labels for items still in the outbox, it is now possible to define a label template for a model (using the Mustache syntax) . This is defined as an attribute (`wq_label_template`) on the _model_ class (rather than the serializer) so that it can be available for use by the `__str__` method. The new `LabelModel` in [wq.db.patterns.models](https://github.com/wq/wq.db/blob/master/patterns/base/models.py) provides an implementation of the `__str__` method. Whether or not you extend `LabelModel`, you can set `wq_label_template` on any model to have the setting propagated to the [wq configuration](https://wq.io/docs/config) object and then used in the outbox (for [wq.app 1.0.0b2 or newer](https://github.com/wq/wq.app/releases/))
- Serializers can now have a `wq_field_config` Meta attribute to customize the form configuration for specific fields. This is primarily to facilitate support for the `filter` configuration option when generating form fields for foreign keys. On the client (wq.app), the filter option is parsed and then passed on to `model.filter()`. On the server (wq.db), the updated `get_lookup_choices()` will take the same setting into account when rendering edit views.

By way of example, here is a model that uses both `wq_label_template` and `wq_field_config`:

python
myapp/models.py
from django.db import models
from wq.db.patterns.models import LabelModel

class Item(LabelModel):
name = models.Model()
type = models.ForeignKey("ItemType")

wq_label_template = "{{name}}"

class ItemType(models.Model):
active = models.BooleanField()
...

myapp/serializers.py
class ItemSerializer(ModelSerializer):
class Meta:
Add the following attributes to the automatically-generated field config for "type"
wq_field_config = {
'type': {
'filter': {
'active': [
Always allow active types
'1',

Allow inactive types when editing existing items
'{{id}}0{{/id}}{{^id}}1{{/id}}',
]
}
}
}

myapp/rest.py
from wq.db import rest
from .models import Item, ItemType
from .serializers import ItemSerializer

rest.router.register_model(
Item,
serializer=ItemSerializer,
fields="__all__",
)
rest.router.register_model(
ItemType,
fields="__all__",
)


The resulting configuration object will look something like this:

javascript
// config.json
{
"pages": {
"item": {
"url": "items",
"list": true,
"label_template": "{{name}}", // copied from model
"form": [{
// ... other fields ...
}, {
"name": "type",
"label": "Type",
"type": "string",
"wq:ForeignKey": "itemtype",
"filter": {"active": ["1", "{{id}}0{{/id}}{{^id}}1{{/id}}"]}, // copied from serializer
"bind": {"required": True}
}]
},
// ... other pages ...
}
}


Other Improvements
- Django compatibility improvements
- Enable `APP_DIRS` support for [django-mustache](https://github.com/wq/django-mustache)
- Support nested [Django Natural Keys](https://github.com/wq/django-natural-keys) in the form configuration object (including natural keys containing one or more foreign keys).
- Don't crash on `HEAD` and `OPTIONS` HTTP verbs
- Fixes for `dump_config`, `wq.db.patterns.identify`, and GeoJSON support

1.0.0b2

Minor update to the [**wq.db 1.0 beta**](https://github.com/wq/wq.db/releases/v1.0.0b1) to ensure [wq.core](https://wq.io/wq.core) knows **wq.db** is installed (a66a929; see wq/wq.core1).

Page 1 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.