django-ewiz
A non-relational Django database backend that utilizes EnterpriseWizard’s REST interface.
- Version:
1.5.4
- Dependencies:
Python 3.4+, Django>=1.5, djangotoolbox>=1.6.2, requests>=2.2.0
- Home page:
- Author:
Alex Kavanaugh <kavanaugh.development@outlook.com>
- License:
GNU LGPL (http://www.gnu.org/licenses/lgpl.html)
NOTE: Versions 1.3+ will work with the EnterpriseWizard anti-sql block. In order to achieve this, regular expression and case-insensitive query operations were removed.
Installation
Run pip install django-ewiz
Add django_ewiz to INSTALLED_APPS
INSTALLED_APPS = (
...
'django_ewiz',
...
)
Usage
Basic Usage
In the DATABASES settings dictionary, simply use django_ewiz as the ENGINE key.
'default': {
'ENGINE': 'django_ewiz',
'NAME': '', # The name of the knowlegebase
'USER': '', # The name of the user
'PASSWORD': '', # The user's password
'HOST': '', # EnterpriseWizard's REST base url, generally 'www.example.com/ewws/'. Don't include the protocol string (e.g. 'http://').
'PORT': '', # Either 80 or 443 (HTTP or HTTPS requests only)
'NUM_CONNECTIONS': '', # Default: 1, Allows multiple concurrent connections to be used when retrieving multiple tickets in a query.
},
That’s it! All database operations performed will be abstracted and should function as the usual engines do (unless what you wish to do conflicts with the options below).
The following query operations are supported:
iexact
icontains
in
gt
gte
lt
lte
istartswith
iendswith
range
year
isnull
The following query operations will be converted to their respective case-insensitive forms: (version 1.3+)
exact
contains
startswith
endswith
The following query operations are no longer supported: (version 1.3+)
regex
iregex
NOTE: Not all ticket fields can be changed via REST. Add editable=False as a model option to remove DatabaseErrors.
File Uploads
django-ewiz does support file uploads - just not in a direct manner (binary uploads to the file field won’t work [more research on abstracting that will be done later])
To mark a field as a file field, add help_text='file' as a model field option. Since trying to modify the field directly won’t work, adding editable=False is recommended to avoid confusion.
file_field = CharField(help_text='file', editable=False, db_column='attached_files')
To upload a file, use the provided EwizAttacher class (from django_ewiz import EwizAttacher) with the following parameters:
settingsDict - the DATABASES dictionary that contains ewiz connection settings. e.g. settings.DATABASES[‘default’]
model - the model instance to which a file should be uploaded (the model must include one and only one file field). e.g. models.AccountRequest.objects.get(ticket_id = 1)
file_reference - a Python file object. If the file is coming from a django form, grab it via request.FILES[‘form_field_name’].file
file_name - the desired file name. If the file is coming from a django form, you can grab its name via request.FILES[‘form_field_name’].name
File Upload Example
forms.py
from django.forms import Form, FileField
class EwizUploadForm(Form):
uploaded_file = FileField(required=True)
models.py
from django.db.models import Model, AutoField, CharField
class AccountRequest(Model):
ticket_id = AutoField(primary_key=True, db_column='id')
subject_username = CharField(help_text=':')
# Use this field only in conjunction with EwizAttacher - do not attempt to directly populate it
file_field = CharField(help_text='file', editable=False, db_column='attached_files')
class Meta:
db_table = u'account_request'
managed = False
verbose_name = u'Account Request'
views.py
from django.conf import settings
from django.views.generic.edit import FormView
from django_ewiz import EwizAttacher
from .forms import EwizUploadForm
from .models import AccountRequest
class UploadDemoView(FormView):
template_name = "ewizdemo.html"
form_class = EwizUploadForm
def form_valid(self, form):
# Create a new account request
ticket = AccountRequest(subject_username=self.request.user.username)
ticket.save()
# Grab the file
file_reference = self.request.FILES['uploaded_file'].file
# Upload the file
EwizAttacher(settings_dict=settings.DATABASES['default'], model=ticket, file_reference=file_reference, file_name=self.request.user.username + u'.pdf').attach_file()
Metadata
Release files for django-ewiz 1.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-ewiz-1.5.4.tar.gz | 26.9 kB | Without provenance | Details for django-ewiz-1.5.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_ewiz-1.5.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_ewiz-1.5.4-py2.py3-none-any.whl |
Total release size: 45.6 kB
Release files / django-ewiz-1.5.4.tar.gz
| Download URL | django-ewiz-1.5.4.tar.gz |
|---|---|
| Size | 26.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f785fbb194a98e69ca0eb7c650fe76c7edb687f3529c00aff68efc1eac2bd824
|
|
BLAKE2b-256 checksum How to use checksums |
9cd666aeb4064e46f9b1ef9950ce4025a1f5cd6a62651f2ed5510c7478d47d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_ewiz-1.5.4-py2.py3-none-any.whl
| Download URL | django_ewiz-1.5.4-py2.py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5655eb9bc693e94753d3f1f164a19dbcb96277ccb26c006411db13fe8de856bc
|
|
BLAKE2b-256 checksum How to use checksums |
68cd216761799db74eae1257a160bd388ea7578f74e742329019257527d85806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-ewiz 1.5.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.